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); // your code goes here final int n = in.nextInt(); ArrayList tArray = new ArrayList<>(); final int[][] ans = new int[n - 1][n - 1]; for(int i = 1; i < n; i++) { for(int j = 1; j < n; j++) { final int i_f = i; final int j_f = j; tArray.add(new Thread(){ @Override public void run() { KnightL k = new KnightL(n); k.xStep = i_f; k.yStep = j_f; ans[i_f - 1][j_f - 1] = k.solve(); k.resetVisited(); } }); } } for(Thread t : tArray) { t.start(); } boolean isAlive = true; while(isAlive) { isAlive = false; for(Thread t : tArray) { isAlive |= t.isAlive(); } } for(int i = 0; i < ans.length; i++) { for(int j = 0; j < ans.length; j++) { System.out.print(ans[i][j] + " "); } System.out.println(); } } } class KnightL { private static final int NOT_VISITED = -1; private int n; public int solCount; private int[][] board; public int xStep; public int yStep; private final Coordinates endPos; public KnightL(int n) { this.n = n; endPos = new Coordinates(n - 1, n - 1); solCount = 0; board = new int[n][n]; resetVisited(); } public void resetVisited() { for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { board[i][j] = NOT_VISITED; } } } public int solve() { int level = 0; Set adjacencyList = getAdjacents(0, 0); boolean isFound = adjacencyList.contains(endPos); while(!adjacencyList.isEmpty() && !isFound) { level++; Set adjacencyList2 = new HashSet<>(); for(Coordinates c : adjacencyList) { Set currAdjacencyList = getAdjacents(c.getX(), c.getY()); if(isFound = currAdjacencyList.contains(endPos)) { break; } else { adjacencyList2.addAll(currAdjacencyList); board[c.getX()][c.getY()] = 0; } } adjacencyList = adjacencyList2; } if(isFound) { return ++level; } else { return -1; } } private Set getAdjacents(int x, int y) { Set adjacencyList = new HashSet<>(); if (x + xStep < n && y - yStep >= 0 && board[x + xStep][y - yStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x + xStep, y - yStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } if (x + yStep < n && y - xStep >= 0 && board[x + yStep][y - xStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x + yStep, y - xStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } if (x - xStep >= 0 && y + yStep < n && board[x - xStep][y + yStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x - xStep, y + yStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } if (x - yStep >= 0 && y + xStep < n && board[x - yStep][y + xStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x - yStep, y + xStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } if (x - xStep >= 0 && y - yStep >= 0 && board[x - xStep][y - yStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x - xStep, y - yStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } if (x - yStep >= 0 && y - xStep >= 0 && board[x - yStep][y - xStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x - yStep, y - xStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } if (x + xStep < n && y + yStep < n && board[x + xStep][y + yStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x + xStep, y + yStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } if (x + yStep < n && y + xStep < n && board[x + yStep][y + xStep] == NOT_VISITED) { Coordinates pos = new Coordinates(x + yStep, y + xStep); if(!adjacencyList.contains(pos)) { adjacencyList.add(pos); } } return adjacencyList; } } class Coordinates { private int x; private int y; public Coordinates(int x, int y) { this.x = x; this.y = y; } public int getX() { return x; } public void setX(int x) { this.x = x; } public int getY() { return y; } public void setY(int y) { this.y = y; } @Override public int hashCode() { int hash = 7; hash = 59 * hash + this.x; hash = 59 * hash + this.y; return hash; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Coordinates other = (Coordinates) obj; if (this.x != other.x) { return false; } if (this.y != other.y) { return false; } return true; } }