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

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m; cin >> n >> m;
	int k = 49999;
	vector<deque<int>> ans(k);
	vector<int> wins(n, 0);
	vector<vector<int>> win(n), lose(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--; b--;
		win[a].push_back(b);
		lose[b].push_back(a);
	}
	for (int i = 0; i < n; i++) {
		sort(lose[i].begin(), lose[i].end());
		reverse(lose[i].begin(), lose[i].end());
		for (int j : lose[i]) ans[i].push_back(j);
		for (int j : ans[i]) wins[j]++;
		ans[i].push_back(i);
		sort(win[i].begin(), win[i].end());
		for (int j : win[i]) ans[i].push_back(j);
		vector<bool> seen(n, false);
		for (int j : ans[i]) seen[j] = true;
		for (int j = 0; j < n; j++) {
			if (!seen[j]) ans[i].push_back(j);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = n; j < k; j++) {
			if (wins[i] < k/2) {
				ans[j].push_front(i);
				wins[i]++;
			} else ans[j].push_back(i);
		}
	}
	cout << "YES\n";
	cout << k << "\n";
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < n; j++) {
			cout << ans[i][j] + 1 << " ";
		}
		cout << "\n";
	}
}