#!/bin/python import sys n = int(raw_input().strip()) # your code goes here def check(a,b,visited): return a < n and a >= 0 and b < n and b >= 0 and not((a,b) in visited) lines_str = [""] * (n - 1) def step(L): next_steps = set() next_steps.add((0,0)) visited = set() it = -1 while len(next_steps) > 0: it += 1 if (n-1,n-1) in next_steps: lines_str[L[0] - 1] += str(it) + " " return None else: # visit every one in next_steps temp_steps = set(next_steps) for step in temp_steps: visited.add(step) next_steps.remove(step) if check( step[0] - L[0], step[1] - L[1], visited): next_steps.add((step[0] - L[0], step[1] - L[1])) if check( step[0] - L[0], step[1] + L[1], visited): next_steps.add((step[0] - L[0], step[1] + L[1])) if check( step[0] + L[0], step[1] - L[1], visited): next_steps.add((step[0] + L[0], step[1] - L[1])) if check( step[0] + L[0], step[1] + L[1], visited): next_steps.add((step[0] + L[0], step[1] + L[1])) if check( step[0] - L[1], step[1] - L[0], visited): next_steps.add((step[0] - L[1], step[1] - L[0])) if check( step[0] - L[1], step[1] + L[0], visited): next_steps.add((step[0] - L[1], step[1] + L[0])) if check( step[0] + L[1], step[1] - L[0], visited): next_steps.add((step[0] + L[1], step[1] - L[0])) if check( step[0] + L[1], step[1] + L[0], visited): next_steps.add((step[0] + L[1], step[1] + L[0])) lines_str[L[0] - 1] += str(-1) + " " for i in range(1,n): for j in range(1,n): step((i,j)) for str in lines_str: print(str)