#include <bits/stdc++.h>
#define ll long long
#define ff first
#define pb push_back
#define ss second
#define endl '\n'
#define y1 y6
#define j1 j6
using namespace std;
ll n,i,o,d,m,j,x,y;
vector < ll > v[100007];
const ll INF=1e9+7;
int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        x--; y--;
        v[x].pb(y);
    }
    for(i=0;i<v[0].size();i++)
    {
        for(o=0;o<v[v[0][i]].size();o++)
        {
            if(v[v[0][i]][o]==0)
            {
                cout<<"1 "<<v[0][i]+1<<" 1";
                return 0;
            }
        }
    }
    cout<<"NO";
    return 0;
}
