#include <iostream>
#include <vector>

using namespace std;

int n, m;
vector<pair<int, int> > g[101010];
vector<int> stk;
int color[101010];
int SZ = 0;
void dfs(int v) {
//    cout << v << " <<< " << endl;
    if (color[v] == 1) {
        if (SZ == n && v == 1) {
            cout << "YES\n";
            for (auto i : stk)cout << i << " ";
            cout << 1;
            exit(0);
        }
        return;
    }
    stk.push_back(v);SZ++;
    color[v] = 1;
    for (auto [to, id] : g[v]) {
        if (color[to] == 1) {
            if (SZ != n)continue;
            if (to != 1)continue;
            dfs(to);
        }
        dfs(to);
    }
    color[v] = 0;
    stk.pop_back();SZ--;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int A, B;
        cin >> A >> B;
        g[A].push_back({B, i});
    }

    dfs(1);
    cout << "NO";
    return 0;
}
/**
5 8
1 2
1 3
1 5
2 3
3 4
4 1
5 3
5 2
*/
