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 i = 1; i < n; i++) { for(int j = 1; j < n; j++) { System.out.print(findMinPath(i, j, n) + " "); } System.out.println(""); } } public static int findMinPath(int xStep, int yStep, int size) { class Visitor{ int x; int y; int counter; public Visitor(int x, int y, int counter){ this.x = x; this.y = y; this.counter = counter; } }; //System.out.println(""); //System.out.println("****************************************"); //System.out.println("("+xStep+", "+yStep+") n = "+size); boolean[][] visited = new boolean[size][size]; int[] xBias = {1, 1, -1, -1}; int[] yBias = {1, -1, 1, -1}; Queue toVisit = new LinkedList<>(); toVisit.add(new Visitor(0,0,0)); while(!toVisit.isEmpty()) { Visitor point = toVisit.poll(); int x = point.x; int y = point.y; if(!visited[x][y]) { visited[x][y] = true; //System.out.println("\tvisiting:("+x+", "+y+") #"+point.counter); if(x == size-1 && y == size-1) { //System.out.println("\tFound at ("+x+", "+y+")"); return point.counter; } for(int i = 0; i < 4; i++) { int newX = x + xStep * xBias[i]; int newY = y + yStep * yBias[i]; if(newX >= 0 && newX < size && newY >= 0 && newY < size) { if(!visited[newX][newY]) { toVisit.add(new Visitor(newX, newY, point.counter+1)); } } } for(int i = 0; i < 4; i++) { int newX = x + yStep * yBias[i]; int newY = y + xStep * xBias[i]; if(newX >= 0 && newX < size && newY >= 0 && newY < size) { if(!visited[newX][newY]) { toVisit.add(new Visitor(newX, newY, point.counter+1)); } } } } } return -1; } }