#include <bits/stdc++.h>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    std::vector<std::vector<int>> is(N  +1, std::vector<int>(N + 1));
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        is[a][b] = true;
        if (is[b][a]) {
            cout << "NO\n";
            return 0;
        }
    }

    std::vector<std::vector<int>> perms;
    for (int a = 0; a < N; a++) {
        for (int b = 0; b < N; b++) {
            if (!is[a][b]) {
                continue;
            }
            std::vector<int> P(N);
            iota(P.begin(), P.end(), 0);
            P.erase(find(P.begin(), P.end(), a));
            P.erase(find(P.begin(), P.end(), b));

//            P.push_back(a);
            P.insert(P.begin(), b);
            P.insert(P.begin(), a);


                perms.push_back(P);
                std::reverse(P.begin(), P.end());
                P.pop_back();
                P.pop_back();
                P.push_back(a);
                P.push_back(b);
                perms.push_back(P);
        }
    }

    std::cout << "YES\n";
    std::cout << perms.size() << "\n";
    for (const auto& line : perms) {
        for (const int x : line) {
            std::cout << x + 1 << " ";
        }
        std::cout << "\n";
    }

    return 0;
}