#pragma GCC Optimize("O3")
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll,ll>pairll;
typedef long double ld;

#define pb push_back
#define fr first
#define sc second
#define INF 1000000000000000007
#define MOD 1000000007
#define endl '\n'

ll n,m,f[100007],sz;

vector<ll>v[100007];

stack<ll>res;

ll S(ll x){
    f[x]=1;
    sz++;
    for(int i=0;i<v[x].size();i++){
        if(f[v[x][i]]==1){
            if(v[x][i]==1 && sz==n){
                res.push(1);
                res.push(x);
                return 1;
            }
        }else{
            ll r=S(v[x][i]);
            if(r==1){
                res.push(x);
                return 1;
            }
        }
    }
    f[x]=0;
    sz--;
    return 0;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cin>>n>>m;
    scanf("%lld %lld", &n, &m);
    for(int i=1;i<=m;i++){
        ll x,y;
        //cin>>x>>y;
        scanf("%lld %lld", &x, &y);
        v[x].pb(y);
    }
    ll r=S(1);
    if(r==0){
        //cout<<"NO"<<endl;
        printf("NO\n");
        return 0;
    }
    //cout<<"YES"<<endl;
    printf("YES\n");
    while(res.size()>0){
        //cout<<res.top()<<" ";
        printf("%lld", res.top());
        printf(" ");
        res.pop();
    }
    //cout<<endl;
    printf("\n");
    
    return 0;

}
