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 i=1; i < n; i++) { for (int j = 1; j < n; j++) { System.out.print(knightL(n, i, j, new Node(0,0,0)) + " "); } System.out.println(""); } } public static int knightL(int n, int i, int j, Node location) { Queue queue = new LinkedList(); List visited = new ArrayList(); queue.add(location); int moves = 0; while (queue.peek() != null) { Node current = queue.poll(); if (current.x == n-1 && current.y == n-1) { return current.moves; } if (visited.contains(current)) { continue; } visited.add(current); for (Node s : validMoves(n, i, j, current, visited)) { queue.add(s); } } return -1; } private static List validMoves(int n, int i, int j, Node location, List visited) { List validMoves = new ArrayList(); if (location.x + i < n && location.y + j < n) { Node next = new Node(location.x + i, location.y + j, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } if (location.x + i < n && location.y - j >= 0) { Node next = new Node(location.x + i, location.y - j, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } if (location.x - i >= 0 && location.y + j < n) { Node next = new Node(location.x - i, location.y + j, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } if (location.x - i >= 0 && location.y - j >= 0) { Node next = new Node(location.x - i, location.y - j, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } // inverse case if (i != j) { if (location.x + j < n && location.y + i < n) { Node next = new Node(location.x + j, location.y + i, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } if (location.x + j < n && location.y - i >= 0) { Node next = new Node(location.x + j, location.y - i, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } if (location.x - j >= 0 && location.y + i < n) { Node next = new Node(location.x - j, location.y + i, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } if (location.x - j >= 0 && location.y - i >= 0) { Node next = new Node(location.x - j, location.y - i, location.moves+1); if (!visited.contains(next)) validMoves.add(next); } } return validMoves; } } class Node { int x; int y; int moves; Node(int x, int y, int moves) { this.x = x; this.y = y; this.moves = moves; } @Override public boolean equals(Object obj) { final Node other = (Node) obj; if (this.x != other.x) { return false; } if (this.y != other.y) { return false; } return true; } }