#!/bin/python3 import sys n = int(input().strip()) # your code goes here from queue import deque def get_Neighbours(p, i, j): potential_neighbours = [ (p[0] + i, p[1] + j), (p[0] + j, p[1] + i), (p[0] - i, p[1] + j), (p[0] - j, p[1] + i), (p[0] + i, p[1] - j), (p[0] + j, p[1] - i), (p[0] - i, p[1] - j), (p[0] - j, p[1] - i) ] neighbours = [] for item in potential_neighbours: if item[0] >= 0 and item[1] >= 0 and item[0] < n and item[1] < n: neighbours.append(item) return neighbours count = [[None for _ in range(n-1)] for _ in range(n-1)] for i in range(1, n): for j in range(i, n): visited = [[False for _ in range(n)] for _ in range(n)] counter = [[float('inf') for _ in range(n)] for _ in range(n)] counter[0][0] = 0 queue = deque([(0, 0)]) while len(queue): cP = queue.pop() if visited[cP[0]][cP[1]]: continue visited[cP[0]][cP[1]] = True neighbours = get_Neighbours(cP, i, j) for item in neighbours: queue.appendleft(item) counter[item[0]][item[1]] = min(counter[item[0]][item[1]], counter[cP[0]][cP[1]] + 1) t = counter[n-1][n-1] if t == float('inf'): count[i-1][j-1] = count[j-1][i-1] = -1 else: count[i-1][j-1] = count[j-1][i-1] = t for i in range(n-1): print(" ".join(list(map(str, count[i]))))