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(); // your code goes here for (int a = 1; a < n; a++) { for (int b = 1; b < n; b++) { System.out.print(KnightL(a, b, n) + " "); } System.out.println(); } } private static int KnightL(int a, int b, int size) { int step = 0; int[][] grid = new int[size][size]; boolean hasNodeBeenPlaced; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { grid[i][j] = -1; } } grid[0][0] = 0; while (true) { step++; hasNodeBeenPlaced = false; for (int row = 0; row < size; row++) { for (int col = 0; col < size; col++) { if (grid[row][col] == step - 1) { if (row + a < size && col + b < size) { if (grid[row+a][col+b] == -1) { grid[row+a][col+b] = step; hasNodeBeenPlaced = true; } } if (row + a < size && col - b > -1) { if (grid[row+a][col-b] == -1) { grid[row+a][col-b] = step; hasNodeBeenPlaced = true; } } if (row - a > -1 && col + b < size) { if (grid[row-a][col+b] == -1) { grid[row-a][col+b] = step; hasNodeBeenPlaced = true; } } if (row - a > -1 && col - b > -1) { if (grid[row-a][col-b] == -1) { grid[row-a][col-b] = step; hasNodeBeenPlaced = true; } } if (row + b < size && col + a < size) { if (grid[row+b][col+a] == -1) { grid[row+b][col+a] = step; hasNodeBeenPlaced = true; } } if (row + b < size && col - a > -1) { if (grid[row+b][col-a] == -1) { grid[row+b][col-a] = step; hasNodeBeenPlaced = true; } } if (row - b > -1 && col + a < size) { if (grid[row-b][col+a] == -1) { grid[row-b][col+a] = step; hasNodeBeenPlaced = true; } } if (row - b > -1 && col - a > -1) { if (grid[row-b][col-a] == -1) { grid[row-b][col-a] = step; hasNodeBeenPlaced = true; } } if (grid[size-1][size-1] != -1) return step; } } } if (!hasNodeBeenPlaced) { break; } } return -1; } } class Node { private int row; private int col; private Node parent; public Node(int row, int col, Node parent) { this.row = row; this.col = col; } public int getCol() { return this.col; } public int getRow() { return this.row; } public Node getParent() { return this.parent; } }