#include <iostream>
#include <set>

using namespace std;

void insertIfValid(set<pair<int, int>>& positions, int n, int x, int y) {
    if (x >= 0 && x < n && y >= 0 && y < n) {
        positions.insert(make_pair(x, y));
    }
}

int knightL(int n, int a, int b) {
    set<pair<int, int>> currPositions;
    currPositions.insert(make_pair(0, 0));

    set<pair<int, int>> visited;
    int numVisited = visited.size();
    visited.insert(make_pair(0, 0));

    for (int i = 0; visited.size() != numVisited; i++) {
        numVisited = visited.size();
        set<pair<int, int>> nextPositions;

        for (auto& pos : currPositions) {
            if (pos.first == n - 1 && pos.second == n - 1) {
                return i;
            }

            insertIfValid(nextPositions, n, pos.first + a, pos.second + b);
            insertIfValid(nextPositions, n, pos.first + a, pos.second - b);
            insertIfValid(nextPositions, n, pos.first - a, pos.second + b);
            insertIfValid(nextPositions, n, pos.first - a, pos.second - b);
            insertIfValid(nextPositions, n, pos.first + b, pos.second + a);
            insertIfValid(nextPositions, n, pos.first + b, pos.second - a);
            insertIfValid(nextPositions, n, pos.first - b, pos.second + a);
            insertIfValid(nextPositions, n, pos.first - b, pos.second - a);
        }
        currPositions = nextPositions;

        for (auto& pos : currPositions) {
            visited.insert(pos);
        }
    }

    return -1;
}

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

    for (int i = 1; i < N; i++) {
        for (int j = 1; j < N; j++) {
            cout << knightL(N, i, j) << " ";
        }
        cout << endl;
    }

    return 0;
}