p109.ans1
======================
3 1 3 7 9
5 2 4 6 8

=================
p109.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n;

void read() { cin >> n; }

void solve() {
    // Colour the N x N board like a checkerboard. Every single move flips the
    // colour of the finger's cell, so after a move the possible positions all
    // share one colour and we can safely remove the other colour's cells.
    //
    // - First turn: K = n moves; remove the upper-right triangle (cells with
    //   i + j > n) to shrink the reachable set.
    //
    // - Then n more turns with odd move counts n+1, n+3, ...: on each turn
    //   remove one anti-diagonal of the surviving region. Using distinct odd
    //   step counts keeps every K_i different and within [n, 300), and after
    //   all turns a single picture remains.

    vector<vector<int>> ans;

    ans.push_back({n});
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i + j > n) {
                ans.back().push_back(i * n + j + 1);
            }
        }
    }

    int q = n + 1;
    if(q % 2 == 0) {
        q++;
    }

    for(int steps = 0; steps < n; steps++) {
        ans.push_back({q});
        int diag_x = 0, diag_y = n - steps;
        if(steps == 0) {
            diag_x = 1;
            diag_y = n - 1;
        }

        while(diag_y >= 0 && diag_x < n) {
            ans.back().push_back(diag_x * n + diag_y + 1);
            diag_x++;
            diag_y--;
        }
        q += 2;
    }

    for(auto it: ans) {
        for(auto x: it) {
            cout << x << ' ';
        }
        cout << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
p109.in1
======================
3

=================
statement.txt
======================
109. Magic of David Copperfield II

time limit per test: 0.25 sec.
memory limit per test: 4096 KB


The well-known magician David Copperfield loves lo show the following trick: a square with N rows and N columns of different pictures appears on a TV screen, Let us number all the pictures in the following order:


1	2	...	N
...	...	...	...
N*(N-1)+1	N*(N-1)+2	...	N*N

Each member of the audience is asked to put a finger on the upper left picture (i.e., picture number one) and The Magic begins: the magician tells the audience to move the finger K1 times through the pictures (each move is a shift of the finger to the adjacent picture up, down, left or right provided that there is a picture to move to), then with a slight movement of his hand he removes some of the pictures with an exclamation "You are not there!", and ... it is true - your finger is not pointing to any of the pictures removed. Then again, he tells the audience to make K2 moves, and so on. At the end he removes all the pictures but one and smiling triumphantly declares, "I've caught you" (applause).

Just now, David is trying to repeat this trick. Unfortunately, he had-a hard day before, and you know how hard to conjure with a headache. You have to write a program that will help David to make his trick.

Input

The input file contains a single integer number N (1<N<101).


Output

Your program should write the following lines with numbers to the output file:
K1 X1,1 X1,2 ... X1,m1
K2 X2,1 X2,2 ... X2,m2
...
Ke Xe,1 Xe,2 ... Xe,me
where Ki is a number of moves the audience should make on the i-th turn (N<=Ki<300). All Ki, should be different (i.e. Ki<>Kj when i<>j). Xi,1 Xi,2 ... Xi,mi are the numbers of the pictures David should remove after the audience will make Ki moves (the number of the pictures removed is arbitrary, but each picture should be listed only once, and at least one picture should be removed on each turn).
A description of the every next turn should begin with a new line. All numbers on each line should be separated by one or more spaces. After e iterations, all pictures except one should be removed.


Sample Input

3
Sample Output

3 1 3 7 9
5 2 4 6 8

=================
