#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int n,a,m,b,u, odleglosc=0, indeks,flaga,lotnisko, czy_spojny;
const int MAXI = 1e6 + 7;
vector <int> graf[MAXI];
vector <int> OddO[MAXI];
bool odw[MAXI];
int wezel_komunikacyjny[MAXI]; //jeśli jest jakieś centrum z którego mozna dotrzec wszedzie
void bfs(int w){
queue <int> q;
q.push(w);
odw[w] = true;
while(q.size())
{
w = q.front();
q.pop();
for(int i : graf[w]){
if(!odw[i]){
odw[i] = true;
q.push(i);
}
}
}
}
void czyszczenie(){
for (int i=0; i<=m; i++)
{
odw[i]=0;
}
}
void dfs(int w){
odw[w]=1;
for (int i=0; i<OddO[w].size(); i++)
{
u=OddO[w][i];
if (!odw[i]) dfs(u);
}
}
int sprawdz(){
for (int i=1; i<=m; i++)
{
//cout << i << " " << odw[i]<<endl;
if (!odw[i]) {
//cout <<"NO\n"<< i << " 1";
return i;
}
}
return 0;
}
void wyswietl(){
for (int i=0; i<=m; i++)
{
cout <<i << " " << odw[i]<<" \n";
}
}
int main() {
cin >>m>>n ;
for (int i=1; i<=n; i++){
cin >> a >> b;
graf[b].push_back(a);
OddO[a].push_back(b);
}
bfs(1);
int gamon=sprawdz();
// wyswietl();
if (gamon!=0)//moze do kazdego miasta
{
cout << "NO\n" <<gamon << " 1";
return 0;
}
czyszczenie();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8cXVldWU+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuLGEsbSxiLHUsIG9kbGVnbG9zYz0wLCBpbmRla3MsZmxhZ2EsbG90bmlza28sIGN6eV9zcG9qbnk7CmNvbnN0IGludCBNQVhJID0gMWU2ICsgNzsKdmVjdG9yIDxpbnQ+IGdyYWZbTUFYSV07CnZlY3RvciA8aW50PiBPZGRPW01BWEldOwpib29sIG9kd1tNQVhJXTsKaW50IHdlemVsX2tvbXVuaWthY3lqbnlbTUFYSV07IC8vamXFm2xpIGplc3QgamFraWXFmyBjZW50cnVtIHoga3TDs3JlZ28gbW96bmEgZG90cnplYyB3c3plZHppZQoKdm9pZCBiZnMoaW50IHcpewogICAgcXVldWUgPGludD4gcTsKICAgIHEucHVzaCh3KTsKICAgIG9kd1t3XSA9IHRydWU7CiAgICB3aGlsZShxLnNpemUoKSkKICAgIHsKICAgICAgICB3ID0gcS5mcm9udCgpOwogICAgICAgIHEucG9wKCk7CiAgICAgICAgICAgIGZvcihpbnQgaSA6IGdyYWZbd10pewogICAgICAgICAgICAgICAgaWYoIW9kd1tpXSl7CiAgICAgICAgICAgICAgICBvZHdbaV0gPSB0cnVlOwogICAgICAgICAgICAgICAgcS5wdXNoKGkpOwogICAgICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQp2b2lkIGN6eXN6Y3plbmllKCl7CiAgICBmb3IgKGludCBpPTA7IGk8PW07IGkrKykKICAgIHsKICAgICAgICBvZHdbaV09MDsKICAgIH0KICAgIAp9CnZvaWQgZGZzKGludCB3KXsKICAgIAogICAgb2R3W3ddPTE7CiAgICAKICAgIGZvciAoaW50IGk9MDsgaTxPZGRPW3ddLnNpemUoKTsgaSsrKQogICAgewogICAgICAgIHU9T2RkT1t3XVtpXTsKICAgICAgICBpZiAoIW9kd1tpXSkgZGZzKHUpOwogICAgfQogICAgCiAgICAKfQppbnQgc3ByYXdkeigpewogICAgZm9yIChpbnQgaT0xOyBpPD1tOyBpKyspCiAgICB7CiAgICAgICAgLy9jb3V0IDw8IGkgPDwgIiAiIDw8IG9kd1tpXTw8ZW5kbDsKICAgICAgICBpZiAoIW9kd1tpXSkgewogICAgICAgICAgICAKICAgICAgICAgICAgLy9jb3V0IDw8Ik5PXG4iPDwgaSA8PCAiIDEiOwogICAgICAgICAgICByZXR1cm4gaTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gMDsKfQp2b2lkIHd5c3dpZXRsKCl7CiAgICAKICAgIGZvciAoaW50IGk9MDsgaTw9bTsgaSsrKQogICAgewogICAgICAgIGNvdXQgPDxpIDw8ICIgIiA8PCAgb2R3W2ldPDwiIFxuIjsKICAgIH0KfQoKaW50IG1haW4oKSB7CmNpbiA+Pm0+Pm4gOwoKZm9yIChpbnQgaT0xOyBpPD1uOyBpKyspewogICAgY2luID4+IGEgPj4gYjsKICAgIGdyYWZbYl0ucHVzaF9iYWNrKGEpOwogICAgT2RkT1thXS5wdXNoX2JhY2soYik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgIApiZnMoMSk7CmludCBnYW1vbj1zcHJhd2R6KCk7CiAgIC8vIHd5c3dpZXRsKCk7CmlmIChnYW1vbiE9MCkvL21vemUgZG8ga2F6ZGVnbyBtaWFzdGEKewogICAgY291dCA8PCAiTk9cbiIgPDxnYW1vbiA8PCAiIDEiOwogICAgcmV0dXJuIDA7Cn0KY3p5c3pjemVuaWUoKTsKCgogICAgCiAgICByZXR1cm4gMDsKfQo=