import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.stream.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] result = new int[n - 1][n - 1]; for (int i = 1; i < n; i++) { for (int j = i; j < n; j++) { int solve = solve(n, i, j); result[i - 1][j - 1] = solve; result[j - 1][i - 1] = solve; } } print(result); } private static int solve(int n, int a, int b) { int[][] desk = new int[n][n]; Queue q = new LinkedList<>(); q.add(new Pair(0, 0)); while (!q.isEmpty()) { Pair p = q.poll(); List moves = getMoves(desk, p, a, b); int depth = desk[p.x][p.y] + 1; for (Pair move : moves) { if (desk[move.x][move.y] == 0) { desk[move.x][move.y] = depth; q.add(move); if(move.x == n - 1 && move.y == n - 1){ return depth; } } } //print(desk); } return -1; } private static void print(int[][] desk) { StringBuffer result = new StringBuffer(); String separator = ","; for (int[] aDesk : desk) { for (int o : aDesk) { result.append(o).append(" "); } result.append("\n"); } System.out.println(result); } private static List getMoves(int[][] desk, Pair current, int a, int b) { int n = desk.length; return Stream.of( new Pair(current.x + a, current.y + b), new Pair(current.x + a, current.y - b), new Pair(current.x - a, current.y + b), new Pair(current.x - a, current.y - b), new Pair(current.x + b, current.y + a), new Pair(current.x + b, current.y - a), new Pair(current.x - b, current.y + a), new Pair(current.x - b, current.y - a)) .filter(p -> p.x >= 0 && p.x < n && p.y >= 0 && p.y < n && desk[p.x][p.y] == 0) .collect(Collectors.toList()); } static class Pair { int x, y; Pair(int x, int y) { this.x = x; this.y = y; } } }