import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class Pair { int _x; int _y; boolean visited = false; public Pair(int x, int y) { _x = x; _y = y; } } private static ArrayList findNeighbors(int x1, int y1, int n, int a, int b) { ArrayList neighbors = new ArrayList(); neighbors.add(new Pair(x1+a,y1+b)); neighbors.add(new Pair(x1+b,y1+a)); neighbors.add(new Pair(x1-a,y1-b)); neighbors.add(new Pair(x1-b,y1-a)); neighbors.add(new Pair(x1-a,y1+b)); neighbors.add(new Pair(x1+a,y1-b)); neighbors.add(new Pair(x1-b,y1+a)); neighbors.add(new Pair(x1+b,y1-a)); return neighbors; } private static boolean isValidMove(Pair p, int n) { if (p._x >= 0 && p._x < n) { if (p._y >= 0 && p._y < n) { return true; } } return false; } public static int KnightL(int x, int y, int a, int b, int n, boolean [][] visitedPairs) { visitedPairs[x][y] = true; if (x == n-1 && y == n-1) return 1; ArrayList neighbors = findNeighbors(x,y,n,a,b); int min = Integer.MAX_VALUE; for (int i = 0; i < neighbors.size(); i++) { Pair p = neighbors.get(i); if (isValidMove(p,n)) { if (!visitedPairs[p._x][p._y]) { int move = 1 + KnightL(p._x,p._y,a,b,n,visitedPairs); if (move != -1) { if (move < min) min = move; } } } } if (min == Integer.MAX_VALUE) return -1; return min; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); boolean [][] visitedBoards = new boolean[n][n]; for(int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (!visitedBoards[i][j]) { boolean [][] visitedPairs = new boolean[n][n]; System.out.print(KnightL(0,0,i,j,n,visitedPairs)-1+" "); visitedBoards[i][j] = true; //visitedBoards[j][i] = true; } } System.out.println(); } } }