#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n, m;
	cin>>n>>m;
	vector<vector<int>> roads(n);
	vector<int> nroads(n, 0);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		roads[a].push_back(b);
		nroads[a]++;
	}
	vector<int> q(n), tick(n, 0);
	int y = 1;
	q[0] = 0;
	int x;
	bool b = false, b1;
	while(y != 0) {
		x = q[y-1];
		if (x == 0 && y!=1) {
			break;
		}
		int j = 0;
		while(j!= nroads[x] && tick[roads[x][j]] != 0) {
			j++;
		}
		if (j!= nroads[x]) {
			q[y] = roads[x][j];
			tick[q[y]]=1;
			y++;
		} else {
			y--;
		}
	}
	if (y == 0) {
		cout<<"NO\n";
	} else {
		cout<<"YES\n";
		for (int i=0;i<y;i++) {
			cout<<q[i]+1<<' ';
		}
		cout<<"\n";
	}
}