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

#define rep(i,b) for(int i = 0; i < b; i++)
#define repp(i,a,b) for(int i = a; i < b; i++)
typedef long long ll;
typedef pair<int,int> p2;
#define sz(x) ((int)x.size())
#define all(x) begin(x),end(x)
typedef vector<int> vi;
#define repe(i, x) for (auto& i : x)

auto start =chrono::high_resolution_clock::now();
int main() {
    int n, m;
    cin >> n >> m;
    int k = 10001;

    vector<vector<vector<int>>> graphs(k, vector<vector<int>>(n));

    vector<p2> beats;
    rep(i,m)
    {
        int a,b;
        cin >> a >> b;
        a--; b--;
        beats.emplace_back(a,b);
    }

    mt19937 rng(233464);
    shuffle(all(beats),rng);

    auto can_insert = [&](vector<vector<int>> g, p2 x)
    {
        int numpop = 0;
        vi indeg(n);
        g[x.first].push_back(x.second);
        rep(i,n) repe(e,g[i])
        {
            indeg[e]++;
        }
        queue<int> q;
        rep(i,n) if (indeg[i]==0) q.push(i);

        while (sz(q))
        {
            int u = q.front();
            q.pop();
            numpop++;

            repe(e,g[u])
            {
                indeg[e]--;
                if (indeg[e]==0){
                    q.push(e);
                }
            }
        }

        return numpop==n;
    };

    for (auto p : beats)
    {
        int a,b;
        tie(a,b) = p;

        vi order(k);
        rep(i,k) order[i]=i;
        shuffle(all(order),rng);

        int succ = 0;
        rep(i,k)
        {
            int u = order[i];
            if (can_insert(graphs[u], p2(a,b)))
            {
                graphs[u][a].push_back(b);
                succ++;
            }
            if (succ*2>k) break;
        }
        if (chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()-start).count()>1800)
        {
            cout << "NO\n";
            return 0;
        }
        //cout << "SUCC" << succ << endl;
        //assert(succ*2>k);
        if (!(succ*2>k))
        {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";

    vector<vector<int>> numbeat(n, vi(n));
    rep(i,k)
    {
        vector<vector<int>> g = graphs[i];
        vi order;
        vi indeg(n);
        rep(i,n) repe(e,g[i])
        {
            indeg[e]++;
        }
        queue<int> q;
        rep(i,n) if (indeg[i]==0) q.push(i);

        while (sz(q))
        {
            int u = q.front();
            q.pop();
            order.push_back(u);

            repe(e,g[u])
            {
                indeg[e]--;
                if (indeg[e]==0){
                    q.push(e);
                }
            }
        }
        //reverse(all(order));
        rep(i,n)
        {
            repp(j,i+1,n)
            {
                numbeat[order[i]][order[j]]++;
            }
        }
        repe(u,order) cout << u+1 << " ";
        cout << "\n";
    }

    repe(b,beats)
    {
        assert(numbeat[b.first][b.second]*2>k);
    }

    cout << endl;

    return 0;
}


/*
      1 
   2068 1 2 3 
    432 1 3 2 
   1269 2 3 1 
   1232 3 1 2 
      1 YES

*/