#include <bits/stdc++.h>
using namespace std;
vector <int> v[100008];
vector <int> p;
int l[100008];
int n, m, i, d;
void dfs(int w){
    l[w] = 1;
    p.push_back(w);
    for(auto x : v[w]){
        if(l[x] == 1){
            p.push_back(x);
            d = 1;
            return;
        }
        if(l[x] == 0){
            dfs(x);
        }
    }
    l[w] = 2;
}
int main() {
    /*ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/

	cin >> n;
    cin >> m;
    int a, b;
    for(i = 1; i <= m; i++){
        cin >> a >> b;
        v[a].push_back(b);
    }
    dfs(1);
    if(d == 0) cout << "NO";
    else {
        cout << "YES" << "\n";
        //reverse(p.begin(), p.end());
        for(auto x : p){
            cout << x << " ";
        }
    }
}
