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(); Solution soln = new Solution(); soln.run(n); } public void run(int n) { Node start = new Node(0, 0); HashMap results = new HashMap(); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (j >= i) { LinkedList nodeQ = new LinkedList(); LinkedList seen = new LinkedList(); start.setPrev(null); nodeQ.push(start); boolean found = false; Node curr = null; while (!nodeQ.isEmpty()) { curr = nodeQ.remove(); int currX = curr.getX(); int currY = curr.getY(); if (currX == n - 1 && currY == n - 1) { found = true; break; } for (int k = 0; k < 8; k++) { Node next; switch(k) { case 0: next = new Node(currX + i, currY + j); break; case 1: next = new Node(currX + i, currY - j); break; case 2: next = new Node(currX - i, currY + j); break; case 3: next = new Node(currX - i, currY - j); break; case 4: next = new Node(currX + j, currY + i); break; case 5: next = new Node(currX + j, currY - i); break; case 6: next = new Node(currX - j, currY + i); break; default: next = new Node(currX - j, currY - i); break; } int nX = next.getX(); int nY = next.getY(); if (nX > n - 1 || nX < 0 || nY > n - 1 || nY < 0) continue; if (!seen.contains(next)) { next.setPrev(curr); seen.add(next); nodeQ.add(next); } } } int cost = -1; if (found) { cost++; while (curr.getPrev() != null) { curr = curr.getPrev(); cost++; } } Node tmp = new Node(i, j); results.put(tmp, cost); System.out.print(cost + " "); } else { Node tmp = new Node(j, i); System.out.print(results.get(tmp) + " "); } } System.out.println(); } } public class Node { private int x; private int y; private Node prev; public Node(int x, int y) { this.x = x; this.y = y; this.prev = null; } public int getX() { return this.x; } public int getY() { return this.y; } public Node getPrev() { return this.prev; } public void setPrev(Node n) { this.prev = n; } @Override public boolean equals(Object o) { if (o instanceof Node) { Node n = (Node)o; return (this.x == n.getX() && this.y == n.getY()); } return false; } @Override public int hashCode() { return Objects.hash(this.x, this.y); } } }