#include <bits/stdc++.h>

using namespace std;

void find_cycle(vector<int> way, int** a,int n,bool& printed){
    int k = way.size();
    if(way[0]==way[k-1]&&k!=1){
        std::cout<<"YES"<<std::endl;
        for(auto it = way.begin();it!=way.end();++it){
            std::cout<<*it<<" ";
        }
        printed = true;
        return ;
    }
    for(int i = 0;i<n;++i){
        if(a[way[k-1] -1][i]!=0){
            way.push_back(i+1);
            find_cycle(way,a,n,printed);
            way.pop_back();
            if(printed){
                return ;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int n;
	cin>>n;
    int m;
    std::cin>>m;
    int** a = new int*[n];
    for(int i = 0;i<n;++i){
        a[i] = new int[n];
        for(int j = 0;j<n;++j){
            a[i][j]=0;
        }
    }

    for(int i = 0;i<m;++i){
        int x,y;
        std::cin>>x>>y;
        --x;
        --y;
        a[x][y] = 1;
    }
    /*for(int i = 0;i<n;++i){
        for(int j = 0;j<n;++j){
            std::cout<<a[i][j]<<" ";
        }
        std::cout<<std::endl;
    }*/
    vector<int> way;
    way.push_back(1);

    bool printed = false;
    find_cycle(way,a,n,printed);
}
