/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Aman deep */ import java.util.*; import java.io.*; public class KnightLonAChessBoard { static int n; public static void main(String[] args) { Scanner scan = new Scanner(System.in); n = scan.nextInt(); for(int i=1;i<n;++i) { for(int j=1;j<n;++j) { System.out.print(BFS(i,j)+" "); } System.out.println(""); } } static int BFS(int a,int b) { int min[][] = new int[n][n]; boolean visited[][] = new boolean[n][n]; visited[0][0] = true; for(int i=0;i<n;++i) Arrays.fill(min[i], -1); min[0][0] = 0; LinkedList<Pair> queue = new LinkedList(); queue.add(new Pair(0,0)); while(!queue.isEmpty()) { Pair p = queue.poll(); int x = p.x; int y = p.y; if(x-a>=0) { if(y-b>=0) if(!visited[x-a][y-b]) { visited[x-a][y-b]= true; min[x-a][y-b] = 1+min[x][y]; queue.add(new Pair(x-a,y-b)); } if(y+b<n) { if(!visited[x-a][y+b]) { visited[x-a][y+b] = true; min[x-a][y+b] = 1+min[x][y]; queue.add(new Pair(x-a,y+b)); } } } if(x+a<n) { if(y-b>=0) { if(!visited[x+a][y-b]) { visited[x+a][y-b] = true; min[x+a][y-b] = 1+min[x][y]; queue.add(new Pair(x+a,y-b)); } } if(y+b<n) { if(!visited[x+a][y+b]) { visited[x+a][y+b] = true; min[x+a][y+b] = 1+min[x][y]; queue.add(new Pair(x+a,y+b)); } } } if(x+b<n) { if(y+a<n) { if(!visited[x+b][y+a]) { visited[x+b][y+a] = true; min[x+b][y+a] = 1+min[x][y]; queue.add(new Pair(x+b,y+a)); } } if(y-a>=0) { if(!visited[x+b][y-a]) { visited[x+b][y-a] = true; min[x+b][y-a] = 1+min[x][y]; queue.add(new Pair(x+b,y-a)); } } } if(x-b>=0) { if(y+a<n) { if(!visited[x-b][y+a]) { visited[x-b][y+a] = true; min[x-b][y+a] = 1+min[x][y]; queue.add(new Pair(x-b,y+a)); } } if(y-a>=0) { if(!visited[x-b][y-a]) { visited[x-b][y-a] = true; min[x-b][y-a] = 1+min[x][y]; queue.add(new Pair(x-b,y-a)); } } } } return min[n-1][n-1]; } static class Pair { int x,y; Pair(int x,int y) { this.x = x; this.y = y; } } }