import java.util.Scanner; public class Main { private static int[][] AnswerArray; private static int N; private static boolean[][] UsedPositions; private static int Distance; private static int a, b; public static void main(String[] args) { Scanner in = new Scanner(System.in); N = in.nextInt(); DeclareAnswerArray(); FillPointsArray(); PrintAnswer(); } private static void DeclareAnswerArray() { AnswerArray = new int[N - 1][N - 1]; for(int x = 0; x < N - 1; x++) { for(int y = 0; y < N - 1; y++) { AnswerArray[x][y] = -1; } } } private static boolean[][] DeclareBooleanArray() { boolean[][] ret = new boolean[N][N]; for(int x = 0; x < N; x++) { for(int y = 0; y < N; y++) { ret[x][y] = false; } } return ret; } private static void FillPointsArray() { boolean[][] NulledUsedPositions = DeclareBooleanArray(); UsedPositions = NulledUsedPositions; for(a = 1; a < N; a++) { for(b = 1; b <= a; b++) { UsedPositions = NulledUsedPositions; Distance = -1; Recursion(0, 0); } } } private static void Recursion(int CurX, int CurY) { UsedPositions[CurX][CurY] = true; Distance++; if(CurX == N - 1 && CurY == N - 1 && (AnswerArray[a - 1][b - 1] > Distance || AnswerArray[a - 1][b - 1] == -1)) { AnswerArray[a - 1][b - 1] = Distance; AnswerArray[b - 1][a - 1] = Distance; UsedPositions[CurX][CurY] = false; Distance--; return; } int NextX, NextY; ///////////////////////////////////////////////////////////// NextX = CurX + a; NextY = CurY - b; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// NextX = CurX + b; NextY = CurY - a; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// NextX = CurX + b; NextY = CurY + a; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// NextX = CurX + a; NextY = CurY + b; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// NextX = CurX - a; NextY = CurY + b; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// NextX = CurX - b; NextY = CurY + a; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// NextX = CurX - b; NextY = CurY - a; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// NextX = CurX - a; NextY = CurY - b; CheckAndCallRecursion(NextX, NextY); //////////////////////////////////////////////////////////// UsedPositions[CurX][CurY] = false; Distance--; } private static void CheckAndCallRecursion(int NextX, int NextY) { if(NextX >= 0 && NextY >= 0 && NextX < N && NextY < N && !UsedPositions[NextX][NextY]) { Recursion(NextX, NextY); } } private static void PrintAnswer() { for(int x = 0; x < N - 1; x++) { for(int y = 0; y < N - 1; y++) { System.out.print(AnswerArray[x][y]); if(y != N - 1) System.out.print(" "); } if(x != N - 1) System.out.print("\n"); } } }