#!/bin/python3 import sys from collections import deque n = int(input().strip()) # your code goes here def find(n, i, j): visited = {} visited[(0,0)] = 0 path = deque() path.append((0,0)) while(len(path) !=0): cell = path.pop() coefs = [(i,j), (-i,j), (i, -j), (-i, -j), (j, i), (-j,i), (j, -i), (-j, -i)] if((cell[0] + i) == n-1 and (cell[1] + j == n-1)) or ((cell[0] +j == n-1) and (cell[1]+i == n-1)): return visited[cell] + 1 for a,b in coefs: # print("cell:", cell, "a:",a, " b:",b) tmp = (cell[0]+a, cell[1] + b) #print(tmp) if(tmp[0] >= 0 ) and (tmp[0] < n) and (tmp[1] >= 0) and (tmp[1] < n) and (not tmp in visited): path.appendleft(tmp) visited[tmp] = visited[cell] + 1 return -1 answer = [] for i in range(n-1): answer.append([]) for j in range(n-1): answer[i].append(0) for i in range(1,n): for j in range (i,n): answer[i-1][j-1] = find(n, i, j) answer[j-1][i-1] = answer[i-1][j-1] for i in range(0,n-1): for j in range (0,n-1): print(answer[i][j], end = " ") print()