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++) { min = Integer.MAX_VALUE; visited = new int[n][n]; for (int k = 0; k < n; k++) { Arrays.fill(visited[k], Integer.MAX_VALUE); } calculateMin(new Node(0, 0), i, j, n, 1); System.out.print((min == Integer.MAX_VALUE ? -1 : min) + " "); } System.out.println(); } } static class Node { final int x; final int y; boolean visited; Node(int x, int y) { this.x = x; this.y = y; } @Override public boolean equals(Object o) { if (!(o instanceof Node)) { return false; } else { Node otherNode = (Node) o; return otherNode.x == this.x && otherNode.y == this.y; } } } static int min; static int[][] visited; public static void calculateMin(Node root, int a, int b, int n, int visitCount) { List adjacents = new ArrayList(); addNode(adjacents, root.x + a, root.y + b, n); addNode(adjacents, root.x + a, root.y - b, n); addNode(adjacents, root.x - a, root.y + b, n); addNode(adjacents, root.x - a, root.y - b, n); addNode(adjacents, root.x + b, root.y + a, n); addNode(adjacents, root.x + b, root.y - a, n); addNode(adjacents, root.x - b, root.y + a, n); addNode(adjacents, root.x - b, root.y - a, n); for (Node r : adjacents) { if (visitCount < visited[r.x][r.y]) { visited[r.x][r.y] = visitCount; //System.out.format("(x,y,count)->(%d,%d,%d)%n", r.x, r.y, visitCount); if (r.x == n - 1 && r.y == n - 1) { min = Math.min(min, visitCount); } calculateMin(r, a, b, n, visitCount + 1); } } } public static void addNode(List list, int x, int y, int n) { if (x >= 0 && x < n && y >= 0 && y < n) { list.add(new Node(x, y)); } } }