#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define st string
#define pb push_back
#define rt return
#define rv reverse
#define sr sort
#define si size()
#define en end()
#define be begin()
#define sc second
#define fr first
#define vl vector < ll >
#define vvl vector < vector < ll > >
#define vs vector < st >
#define vvs vector < vector < st > >
#define pall pair < ll , ll >
#define pasl pair < st , ll >
#define pals pair < ll , st >
using namespace std;
vvl v(100005);
ll a[100005];
ll n,m,lk=0;
vl vr;
void dfs(ll x,ll k)
{
        a[x]=1;
         for (int i=0;i<v[x].si;++i)
         {
             if (a[v[x][i]]==1)
             {
                 if (k==n && v[x][i]==1)
                 {
                     cout << "YES\n";
                     lk=1;
                     vr.pb(1);
                     vr.pb(x);
                  return;
                 }
             }else
             {
                 dfs(v[x][i],k+1);
                 if (lk!=0)
                 {
                     vr.pb(x);
                     return ;
                 }

             }
         }
         a[x]=2;
         return;
}

int main()
{

    cin >> n >> m;
    for (int i=0;i<m;++i)
    {
        ll a,b;
        cin >> a >> b;
        v[a].pb(b);
    }
    dfs(1,1);
    if (lk==1)
    for (int i=vr.si-1;i>=0;--i)
        cout << vr[i] << " ";
    else
    cout << "NO";
}
