import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static int n = 0; public static void main(String[] args) { Scanner in = new Scanner(System.in); n = in.nextInt(); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { int[][] nt = new int[n][n]; nt[0][0] = 1; System.out.print(KnightL(i, j, nt) + " "); } System.out.print("\n"); } // your code goes here } public static int KnightL(int i, int j, int[][] nt) { exec(i, j, nt, 0, 0, 0); int result = nt[n - 1][n - 1]; if (result == 0) return -1; else return result; } public static void exec(int i, int j, int[][] nt, int x, int y, int move) { tryMove(nt, x, y, i, j, move + 1); tryMove(nt, x, y, i, -j, move + 1); tryMove(nt, x, y, -i, j, move + 1); tryMove(nt, x, y, -i, -j, move + 1); if (i != j) { tryMove(nt, x, y, j, i, move + 1); tryMove(nt, x, y, j, -i, move + 1); tryMove(nt, x, y, -j, i, move + 1); tryMove(nt, x, y, -j, -i, move + 1); } } public static void tryMove(int[][] nt, int x, int y, int i, int j, int move) { int tmpX = x + i; int tmpY = y + j; if (tmpX < n && tmpX >= 0 && tmpY < n && tmpY >= 0) { if (nt[tmpX][tmpY] == 0 || nt[tmpX][tmpY] > move) { nt[tmpX][tmpY] = move; exec(i, j, nt, tmpX, tmpY, move); } } } }