import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class Pair { public int x; public int y; public int counter = 0; public Pair(int x, int y, int c) { this.x = x; this.y = y; this.counter = c; } } static class Coordinates { private boolean[][] visited; private int[][] distance; private int n; public Coordinates(int n) { visited = new boolean[n][n]; distance = new int[n][n]; this.n = n; } public int getDistance() { int n = distance.length - 1; return distance[n][n]; } private void clearState() { for (int[] row: distance) { Arrays.fill(row, -1); } for (boolean[] row: visited) { Arrays.fill(row, false); } } public void solve(int a, int b) { clearState(); LinkedList stack = new LinkedList<>(); PriorityQueue pq = new PriorityQueue<>((p1,p2) -> p1.counter - p2.counter); //stack.push(new Pair(a, b, 1)); //stack.push(new Pair(b, a, 1)); pq.add(new Pair(0, 0, 0)); visited[0][0] = true; while (!pq.isEmpty()) { Pair e = pq.poll(); //stack.pop(); if (e.x == n - 1 && e.y == n - 1) break; checkAndAdd(e.x + a, e.y + b, e.counter + 1, pq); checkAndAdd(e.x + a, e.y - b, e.counter + 1, pq); checkAndAdd(e.x - a, e.y + b, e.counter + 1, pq); checkAndAdd(e.x - a, e.y - b, e.counter + 1, pq); if (a != b) { checkAndAdd(e.x + b, e.y + a, e.counter + 1, pq); checkAndAdd(e.x + b, e.y - a, e.counter + 1, pq); checkAndAdd(e.x - b, e.y + a, e.counter + 1, pq); checkAndAdd(e.x - b, e.y - a, e.counter + 1, pq); } } } private void checkAndAdd(int x, int y, int c, PriorityQueue pq) { if (x >= 0 && y >= 0 && x < n && y < n && !visited[x][y]) { visited[x][y] = true; distance[x][y] = c; pq.add(new Pair(x, y, c)); } } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Coordinates c = new Coordinates(n); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (j > 1) System.out.print(" "); c.solve(i, j); System.out.print(c.getDistance()); } System.out.println(); } } }