#!/bin/python3 import sys n = int(input().strip()) # your code goes here def possibles(i,j,x,y,n): p = [] for c in range(-1,2,2): for d in range(-1,2,2): for (a,b) in [(i,j), (j,i)]: tx = x+a*c ty = y+b*d if tx >= 0 and tx < n and ty >= 0 and ty < n: p.append((tx,ty)) return p def dijkstra(a, b, tx, ty, n): x = 0 y = 0 visited = [] toVisit = [(x,y)] distance = {(x,y):0} while len(toVisit) > 0: current = toVisit[0] for node in possibles(a, b, current[0], current[1], n): if node not in visited and node not in toVisit: toVisit.append(node) #print("added node (%d,%d)"%(node[0], node[1]), file=sys.stderr) distance[node] = distance[current]+1 else: distance[node] = min(distance[node], distance[current]+1) toVisit.remove(current) visited.append(current) if (tx,ty) in distance: return distance[(tx,ty)] #print("No path for a=%d, b=%d, tx=%d, ty=%d" % (a,b,tx,ty)) #print(distance) return -1 for a in range(1, n): for b in range(1, n): d = dijkstra(a, b, n-1, n-1, n) print(d, end=" ") print()