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(); for(int a = 1; a < n; a++){ for(int b = 1; b < n; b++){ boolean[][] visited = new boolean[n][n]; Node node = new Node(0,0); node.depth = 0; Queue graph = new LinkedList(); graph.add(node); boolean found = false; for (Node i; (i = graph.poll()) != null;){ if(i.x == n-1 && i.y == n-1){ System.out.print(i.depth + " "); found = true; } i.checkMoves(a, b, visited, graph, n); } if(!found){ System.out.print("-1 "); } } System.out.println(""); } // your code goes here } } class Node{ public int x; public int y; public int depth; public Node parent; public Queue childs; public Node(int x, int y){ this.x = x; this.y = y; } public void addChild(Node node, boolean[][] visited, Queue g, int n){ if(childs == null){ childs = new LinkedList(); } if(node.isValidMove(visited, n)){ visited[node.x][node.y]=true; node.parent = this; node.depth = depth+1; childs.add(node); g.add(node); } } public void checkMoves(int a, int b, boolean[][] visited, Queue g, int n){ Node n1 = new Node(x+a,y+b); addChild(n1,visited,g,n); Node n2 = new Node(x+a,y-b); addChild(n2,visited,g,n); Node n3 = new Node(x-a,y+b); addChild(n3,visited,g,n); Node n4 = new Node(x-a,y-b); addChild(n4,visited,g,n); Node n5 = new Node(x+b,y+a); addChild(n5,visited,g,n); Node n6 = new Node(x+b,y-a); addChild(n6,visited,g,n); Node n7 = new Node(x-b,y+a); addChild(n7,visited,g,n); Node n8 = new Node(x-b,y-a); addChild(n8,visited,g,n); } public boolean isValidMove(boolean[][] visited, int n){ if(x >= 0 && x < n && y >= 0 && y < n && !visited[x][y]){ return true; }else{ return false; } } }