#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

void disp_vecmat (vector<vector<int>> M) {
    for (int i = 0; i < M.size(); i++ ) {
        for (int j = 0; j < M[i].size(); j++ ) {
            cout << M[i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;
}

int main(){
    int n;
    cin >> n;
    
    for (int a = 1; a < n; a++){
    for (int b = 1; b < n; b++){
//        cout << "a = " << a << endl;
//        cout << "b = " << b << endl;
    int x;
    int y;
    
    int stop = 0;
    int counter = 0;
    vector<vector<int>> X; 
    vector<vector<int>> Y;
    vector<int> tempx;
    vector<int> tempy;
    tempx.push_back(0);
    tempy.push_back(0);
    X.push_back(tempx);
    Y.push_back(tempy);
    tempx.clear();
    tempy.clear();
//    disp_vecmat(X);
    while (stop == 0) {
        for (int i = 0; i < X[counter].size(); i++) {
            x = X[counter][i];
            y = Y[counter][i];
            if ((x + a) >= 0 && (x + a) < n && (y + b) >= 0 && (y + b) < n) {
                if (x + a == n-1 && y + b == n-1) {
                    cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x + a);
                tempy.push_back(y + b);
            }
            if ((x - a) >= 0 && (x - a) < n && (y + b) >= 0 && (y + b) < n) {
                if (x - a == n-1 && y + b == n-1) {
                    cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x - a);
                tempy.push_back(y + b);
            }
            if ((x + b) >= 0 && (x + b) < n && (y + a) >= 0 && (y + a) < n) {
                if (x + b == n-1 && y + a == n-1) {
                    cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x + b);
                tempy.push_back(y + a);
            }
            if ((x - b) >= 0 && (x - b) < n && (y + a) >= 0 && (y + a) < n) {
                if (x - b == n-1 && y + a == n-1) {
                    cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x - b);
                tempy.push_back(y + a);
            }
            if ((x + a) >= 0 && (x + a) < n && (y - b) >= 0 && (y - b) < n) {
                if (x + a == n-1 && y - b == n-1) {
                   cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x + a);
                tempy.push_back(y - b);
            }
            if ((x - a) >= 0 && (x - a) < n && (y - b) >= 0 && (y - b) < n) {
                if (x - a == n-1 && y - b == n-1) {
                    cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x - a);
                tempy.push_back(y - b);
            }
            if ((x + b) >= 0 && (x + b) < n && (y - a) >= 0 && (y - a) < n) {
                if (x + b == n-1 && y - a == n-1) {
                    cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x + b);
                tempy.push_back(y - a);
            }
            if ((x - b) >= 0 && (x - b) < n && (y - a) >= 0 && (y - a) < n) {
                if (x - b == n-1 && y - a == n-1) {
                    cout << counter + 1 << ' ';
                    stop = 1;
                    break;
                }
                tempx.push_back(x - b);
                tempy.push_back(y - a);
            }  
        }
    
        X.push_back(tempx);
        tempx.clear();
        Y.push_back(tempy);
        tempy.clear();
        counter++;
        if (counter > 2*n) {
            cout << -1 << ' ';
            stop = 1;
        }
        
        
//        disp_vecmat(X);
//        disp_vecmat(Y);
    }
        
    }
        cout << endl;
    }
        
    return 0;
}