import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int visited[][] = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { visited[i][j] = -1; } } int output[][] = new int[n - 1][n - 1]; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { output[i - 1][j - 1] = walk(0, 0, n, i, j, visited, 0); for (int i1 = 0; i1 < n; i1++) { for (int j1 = 0; j1 < n; j1++) { visited[i1][j1] = -1; } } } } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { System.out.print(output[i][j] + " "); } System.out.println(); } } public static int walk(int x, int y, int n, int a, int b, int[][] visited, int count) { if (x < 0 || y < 0 || x > n - 1 || y > n - 1) { return -1; } else if (x == n - 1 && y == n - 1) { visited[x][y] = count; return count; } else if (visited[x][y] > -1 && visited[x][y] <= count) { return -1; } // if(visited[x][y] > count){ // visited[x][y] = count; // } visited[x][y] = count; count++; int x1 = x + a; int y1 = y + b; int x2 = x + a; int y2 = y - b; int x3 = x - a; int y3 = y + b; int x4 = x - a; int y4 = y - b; int x5 = x + b; int y5 = y + a; int x6 = x + b; int y6 = y - a; int x7 = x - b; int y7 = y + a; int x8 = x - b; int y8 = y - a; if (x1 == n - 1 && y1 == n - 1) { visited[x1][y1] = count; return count; } if (x2 == n - 1 && y2 == n - 1) { visited[x2][y2] = count; return count; } if (x3 == n - 1 && y3 == n - 1) { visited[x3][y3] = count; return count; } if (x4 == n - 1 && y4 == n - 1) { visited[x4][y4] = count; return count; } if (x5 == n - 1 && y5 == n - 1) { visited[x5][y5] = count; return count; } if (x6 == n - 1 && y6 == n - 1) { visited[x6][y6] = count; return count; } if (x7 == n - 1 && y7 == n - 1) { visited[x7][y7] = count; return count; } if (x8 == n - 1 && y8 == n - 1) { visited[x8][y8] = count; return count; } int c1 = -1, c2 = -1, c3 = -1, c4 = -1, c5 = -1, c6 = -1, c7 = -1, c8 = -1; int temp1 = count; if (!(x1 < 0 || y1 < 0 || x1 > n - 1 || y1 > n - 1)) { c1 = walk(x1, y1, n, a, b, visited, temp1); } if (!(x2 < 0 || y2 < 0 || x2 > n - 1 || y2 > n - 1)) { c2 = walk(x2, y2, n, a, b, visited, temp1); } if (!(x3 < 0 || y3 < 0 || x3 > n - 1 || y3 > n - 1)) { c3 = walk(x3, y3, n, a, b, visited, temp1); } if (!(x4 < 0 || y4 < 0 || x4 > n - 1 || y4 > n - 1)) { c4 = walk(x4, y4, n, a, b, visited, temp1); } if (!(x5 < 0 || y5 < 0 || x5 > n - 1 || y5 > n - 1)) { c5 = walk(x5, y5, n, a, b, visited, temp1); } if (!(x6 < 0 || y6 < 0 || x6 > n - 1 || y6 > n - 1)) { c6 = walk(x6, y6, n, a, b, visited, temp1); } if (!(x7 < 0 || y7 < 0 || x7 > n - 1 || y7 > n - 1)) { c7 = walk(x7, y7, n, a, b, visited, temp1); } if (!(x8 < 0 || y8 < 0 || x8 > n - 1 || y8 > n - 1)) { c8 = walk(x8, y8, n, a, b, visited, temp1); } int min = -1; if (c1 >= 0 && (c1 < min || min == -1)) { min = c1; } if (c2 >= 0 && (c2 < min || min == -1)) { min = c2; } if (c3 >= 0 && (c3 < min || min == -1)) { min = c3; } if (c4 >= 0 && (c4 < min || min == -1)) { min = c4; } if (c5 >= 0 && (c5 < min || min == -1)) { min = c5; } if (c6 >= 0 && (c6 < min || min == -1)) { min = c6; } if (c7 >= 0 && (c7 < min || min == -1)) { min = c7; } if (c8 >= 0 && (c8 < min || min == -1)) { min = c8; } return min; } }