#include <bits/stdc++.h>
#define int long long
using namespace std;

vector<vector<int>> G;
vector<bool> visits;
vector<int> len;
stack<int> buffer;
stack<int> cycle;
bool exists = false;
void DFS(int start, int q)
{
	visits[start]=1;
	buffer.push(start);
	for (auto i:G[start])
	{
		if (!visits[i] and len[i]<=len[start])
		{
			len[i]=len[start]+1;
			DFS(i,q+1);
		}
		else
		{
			//cout << i << ' ' << start << ' ' << q << endl;
			if (!exists and i==1 and q == (visits.size() - 1))
			{
				//cout << '=';
				buffer.push(1);
				cycle = buffer;
				exists = true;
				buffer.pop();
			}
		}
	}
	visits[start]=0;
	buffer.pop();
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	G.resize(n+1);
	visits.assign(n+1,0);
	len.assign(n+1,0);
	for (int i=0;i<m;i++)
	{
		int u,v;
		cin >> u >> v;
		G[u].push_back(v);
	}
	len[1]=1;
	DFS(1,1);
	if (exists)
	{
		cout << "YES" << endl;
		vector<int> res;
		while(!cycle.empty())
		{
			res.push_back(cycle.top());
			cycle.pop();
		}
		reverse(res.begin(),res.end());
		for (auto i:res) cout << i << ' ';
		return 0;
	}
	cout << "NO";
	
}