import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int solver(int n, int a, int b) { int[][] grid = new int[n][n]; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid.length; j++) { grid[i][j]=-1; } } backstep(a,b,n-1,n-1,grid,0); return grid[0][0]; } static void backstep (int a, int b, int r, int c, int[][] grid, int count) { int n = grid.length; //I am at . grid[r][c] is the min steps to get from me to if (r >= n || r< 0 || c >= n || c < 0) { return; } else if (grid[r][c] != -1 && count >=grid[r][c]) { return; //been here already, and this is worse } else { grid[r][c] = count; } count++; backstep(a,b,r+a,c+b,grid,count); backstep(a,b,r+a,c-b,grid,count); backstep(a,b,r-a,c+b,grid,count); backstep(a,b,r-a,c-b,grid,count); backstep(a,b,r+b,c+a,grid,count); backstep(a,b,r+b,c-a,grid,count); backstep(a,b,r-b,c+a,grid,count); backstep(a,b,r-b,c-a,grid,count); } 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((j==1? "": " ")+solver(n,i,j)); } System.out.println(""); } } }