#include<bits/stdc++.h>

using namespace std;

#define endl '\n'
#define DIM 1003
#define INF 1000000009

long long n,m,flag,v1,v2;
vector<long long > p,used;
vector<vector<long long>> a;
void dfs(long long v){

    if(flag == 1) return;
    else {
        used[v] = 1;
        p.push_back(v);
        for(int i =0; i<a[v].size(); i++){

            int t = a[v][i];
            if(used[t] == 1){
                p.push_back(t);
                flag = 1;
                return;


            }
            else {
                dfs(t);
            }
            if(flag == 1) return;
        }
        used[v] = 2;
        p.pop_back();


    }
}




void chek(){
    for(int i =1; i<=n+1; i++){

        if(used[i] == 0){
            dfs(i);
            if (flag==1) return;
        }
    }

}


int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    a.resize(n+1);
    used.resize(n+1,0);
    for(int i =0; i<m; i++){

        cin >> v1 >> v2;
        a[v1].push_back(v2);

    }
    chek();
    if(flag == 1){
        int i =p.size()-2;
        int t = p.back();
        while(p[i]!=t) i --;
        cout <<"YES"<<endl;
        while(i < p.size()){
            cout << p[i] <<" ";
            i++;
        }
        cout <<endl;
    }

    else cout <<"NO";

  return 0;
}
