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

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

    int n; cin >> n;
    if(n==2)
        cout << "1 4" << endl << "2 3" << endl;
    else if(n==3)
        cout << "2 1 6" << endl << "5 3 4" << endl;
    else if(n==4)
        cout << "2 8 1 7" << endl << "4 6 3 5" << endl;
    else if(n==5)
        cout << "3 9 1 10 2" << endl << "6 7 4 8 5" << endl;

    return 0;
}