import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static class Graph { // ukuran papan private int size, a, b; private Node root; private Node destination; private LinkedList nextToVisit = new LinkedList<>(); private LinkedList visited = new LinkedList<>(); public class Node { int x, y; int level; LinkedList adjacent = new LinkedList<>(); private Node(int x, int y) { this.x = x; this.y = y; this.level = 9999; } @Override public boolean equals(Object obj) { Node n = (Node) obj; if (this.x == n.x && this.y == n.y) return true; return super.equals(obj); } } public Graph(int size, int a, int b) { this.size = size; this.a = a; this.b = b; this.root = new Node(0, 0); this.root.level = 0; this.destination = new Node(size - 1, size - 1); nextToVisit.add(root); visited.add(root); } public void addChild(Node node, Node child) { if (visited.contains(child)) { child = null; } else { if (child.level > node.level) child.level = node.level + 1; node.adjacent.add(child); nextToVisit.add(child); visited.add(child); } } public void addEdge(Node node) { if (node.x - a >= 0 && node.y - b >= 0) { Node child = new Node(node.x - a, node.y - b); addChild(node, child); } if (node.x - a >= 0 && node.y + b < size) { Node child = new Node(node.x - a, node.y + b); addChild(node, child); } if (node.x + a < size && node.y - b >= 0) { Node child = new Node(node.x + a, node.y - b); addChild(node, child); } if (node.x + a < size && node.y + b < size) { Node child = new Node(node.x + a, node.y + b); addChild(node, child); } if (node.x - b >= 0 && node.y - a >= 0) { Node child = new Node(node.x - b, node.y - a); addChild(node, child); } if (node.x - b >= 0 && node.y + a < size) { Node child = new Node(node.x - b, node.y + a); addChild(node, child); } if (node.x + b < size && node.y - a >= 0) { Node child = new Node(node.x + b, node.y - a); addChild(node, child); } if (node.x + b < size && node.y + a < size) { Node child = new Node(node.x + b, node.y + a); addChild(node, child); } } public int hasPathBFS() { while (!nextToVisit.isEmpty()) { Node node = nextToVisit.remove(); if (node.equals(destination)) return node.level; addEdge(node); } return -1; } } 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++) { Graph g = new Graph(n, a, b); System.out.print(String.valueOf(g.hasPathBFS()) + " "); } System.out.println(); } } }