import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class Node{ int i; int j; int previousMoves; Node(int i, int j, int previousMoves){ this.i = i; this.j = j; this.previousMoves = previousMoves; } } private static int calculateMinimumMoves(int a, int b, int n){ // i * 25 + j Set visitedNodes = new HashSet(); int movesCounter = 0; Queue nodesToVisit = new LinkedList(); nodesToVisit.add(new Node(0,0,0)); while (!nodesToVisit.isEmpty()){ Node currentNode = nodesToVisit.remove(); int currentI = currentNode.i; int currentJ = currentNode.j; if (currentI < 0 || currentI >=n || currentJ < 0 || currentJ >=n || visitedNodes.contains(currentI*25 + currentJ)){ continue; } if (currentI == n-1 && currentJ == n - 1){ return currentNode.previousMoves; } visitedNodes.add(currentI*25 + currentJ); nodesToVisit.add(new Node(currentI + a, currentJ + b, currentNode.previousMoves + 1)); nodesToVisit.add(new Node(currentI + a, currentJ - b, currentNode.previousMoves + 1)); nodesToVisit.add(new Node(currentI - a, currentJ + b, currentNode.previousMoves + 1)); nodesToVisit.add(new Node(currentI - a, currentJ - b, currentNode.previousMoves + 1)); nodesToVisit.add(new Node(currentI + b, currentJ + a, currentNode.previousMoves + 1)); nodesToVisit.add(new Node(currentI + b, currentJ - a, currentNode.previousMoves + 1)); nodesToVisit.add(new Node(currentI - b, currentJ + a, currentNode.previousMoves + 1)); nodesToVisit.add(new Node(currentI - b, currentJ - a, currentNode.previousMoves + 1)); } return -1; } 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 (calculateMinimumMoves(i,j,n)+ " "); } System.out.println(); } } }