import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int[][] knightL; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.close(); // your code goes here knightL = new int[n - 1][n - 1]; for (int i = 1; i < n; i++) { for (int j = i; j < n; j++) { findPath(n, new Cell(0, 0), i, j, new HashSet()); } } // Updating the left diagonal mirror array (it'll same as the right // diagonal half). for (int i = 1; i < n; i++) { for (int j = i; j < n; j++) { knightL[j - 1][i - 1] = knightL[i - 1][j - 1]; } } for (int i = 0; i < knightL.length; i++) { for (int j = 0; j < knightL.length; j++) { System.out.print((knightL[i][j] - 1) + " "); } System.out.println(); } } private static int findPath(int n, Cell c, int a, int b, Set visited) { // Checking for out of bound indexes. if (c.x < 0 || c.y < 0 || c.x >= n || c.y >= n) { return -1; } // If the cell already visited, then leaving it. if (visited.add(c) == false) { return -1; } // If there is a shortest path already found then ignoring the current // path. int low = knightL[a - 1][b - 1]; if (low > 0 && visited.size() > low) { return -1; } // If reached the destination then marking the path distance. if (c.x == n - 1 && c.y == n - 1) { return visited.size(); } // Preparing all the possible next cells. Cell[] cells = new Cell[] { new Cell(c.x + a, c.y + b), new Cell(c.x + a, c.y - b), new Cell(c.x - a, c.y + b), new Cell(c.x - a, c.y - b), new Cell(c.x + b, c.y + a), new Cell(c.x + b, c.y - a), new Cell(c.x - b, c.y + a), new Cell(c.x - b, c.y - a) }; for (Cell cell : cells) { int count = findPath(n, cell, a, b, new HashSet(visited)); // If the path distance is available and is lower than the // previously found, then adding it to the KnightL matrix. if (count > 0 && (low == 0 || low == -1 || count < low)) { knightL[a - 1][b - 1] = count; } } return -1; } static class Cell { int x, y; public Cell(int x, int y) { this.x = x; this.y = y; } public boolean equals(Object obj) { Cell c = (Cell) obj; return x == c.x && y == c.y; } public int hashCode() { return (x + "," + y).hashCode(); } public String toString() { return "[" + x + "," + y + "]"; } } }