/* Copyright (C) 2009 Igor V. Burago */

#include <cassert>
#include <fstream>
#include <vector>

using namespace std;


int main()
{
    ifstream input("input.txt");
    ofstream output("output.txt");

    int runners_num;
    int pairs_num;
    assert(input >> runners_num >> pairs_num);
    assert(2 <= runners_num && runners_num <= 100);

    vector<int> antipode(runners_num, -1);
    vector< pair<int, int> > pairs;
    pairs.reserve(pairs_num);
    for (int pos = 0; pos < pairs_num; ++pos)
    {
        int first;
        int second;
        assert(input >> first >> second);
        assert(1 <= first && first <= runners_num);
        assert(1 <= second && second <= runners_num && first != second);
        pairs.push_back(make_pair(--first, --second));
        assert(antipode[first] == -1 && antipode[second] == -1);
        antipode[first] = second;
        antipode[second] = first;
    }

    vector<int> order;
    order.reserve(runners_num);
    for (int player = 0; player < runners_num; ++player)
        if (antipode[player] == -1)
            order.push_back(player);
    for (int pos = 0; pos < pairs_num; ++pos)
        order.push_back(pairs[pos].first);
    for (int pos = 0; pos < pairs_num; ++pos)
        order.push_back(pairs[pos].second);

    output << runners_num << endl;
    for (int round = 0; round < runners_num; ++round)
    {
        for (int offset = round; offset < round + runners_num - 1; ++offset)
            output << order[offset % runners_num] + 1 << ' ';
        output << endl;
    }

    return 0;
}
