import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static final boolean DEBUG = false; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] moves = new int[n - 1][n - 1]; for (int i = 1; i < n; i++) { for (int j = i; j < n; j++) { if (i == j) { moves[i - 1][j - 1] = getMoves(n, i, j); } else { moves[i - 1][j - 1] = go(n, i, j); } } } // output for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { if (j < i) { System.out.print(moves[j][i] + " "); } else { System.out.print(moves[i][j] +" "); } } System.out.println(); } } public static int go(int n, int i, int j) { boolean discovered[][] = new boolean[n][n]; int[] counter = new int[] {-1}; Stack stack = new Stack(); stack.push(new Point(0, 0)); discover(stack, discovered, n, i, j, counter); return counter[0]; } public static void discover(Stack stack, boolean[][] discovered, int n, int i, int j, int[] counter) { if (!stack.isEmpty()) { Point p = stack.pop(); counter[0] += 1; if (DEBUG) System.out.println("Discovered point: "+p); discovered[p.x][p.y] = true; if (p.x != n - 1 || p.y != n - 1) { pushReachable(n, p.x, p.y, i, j, stack, discovered); discover(stack, discovered, n, i, j, counter); } } else { counter[0] = -1; } } public static void pushReachable(int n, int x, int y, int i, int j, Stack stack, boolean[][] discovered) { if (point(n, x + i, y + j, stack, discovered) || point(n, x + i, y - j, stack, discovered) || point(n, x - i, y + j, stack, discovered) || point(n, x - i, y - j, stack, discovered) || point(n, x + j, y + i, stack, discovered) || point(n, x + j, y - i, stack, discovered) || point(n, x - j, y + i, stack, discovered) || point(n, x - j, y - i, stack, discovered)) { return; } } private static boolean point(int n, int newx, int newy, Stack stack, boolean[][] discovered) { if (newx < 0 || newy < 0 || newx > n - 1 || newy > n - 1 || discovered[newx][newy]) { return false; } stack.push(new Point(newx, newy)); if (DEBUG) System.out.println("\t reachable ("+newx+","+newy+")" ); if (newx == n - 1 && newy == n -1 ) { return true; } return false; } public static int getMoves(int n, int i, int j) { if (i == j && (n - 1) % i == 0) { return (n - 1) / i; } else { return -1; } } public static class Point { public final int x; public final int y; public Point(int x, int y) { this.x = x; this.y = y; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + x; result = prime * result + y; return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Point other = (Point) obj; if (x != other.x) return false; if (y != other.y) return false; return true; } @Override public String toString() { return "(" + x + ", " + y + ")"; } } }