#!/bin/python import sys from collections import deque def valid(node, amend, limit): one = node[0] + amend[0] two = node[1] + amend[1] if one < 0 or one >= limit: return False if two < 0 or two >= limit: return False return True def validSingle(node, limit): return (node[0] >= 0 or node[0] < limit) and (node[1] >= 0 or node[1] < limit) def distance(n, start, goal, s): q = deque() price = [[float('inf')]*n for _ in range(n)] price[start[0]][start[1]] = 0 combinations = ((-s[0], -s[1]), (-s[0], s[1]), (s[0], -s[1]), (s[0], s[1]), (-s[1], -s[0]), (-s[1], s[0]), (s[1], -s[0]), (s[1], s[0])) q.append((start, 0)) # node, parentprice # print price while len(q) > 0: node = q.popleft() ## visit node here for comb in combinations: new = (node[0][0]+comb[0], node[0][1]+comb[1]) # print new, node if valid(node[0], comb, n) and price[new[0]][new[1]] > node[1] + 1: # if validSingle(node[0], n) and price[new[0]][new[1]] > node[1] + 1: q.append(((node[0][0] + comb[0], node[0][1] + comb[1]), node[1] + 1)) price[new[0]][new[1]] = node[1] + 1 for idx in xrange(len(price)): for jdx in xrange(len(price[0])): if price[idx][jdx] == float('inf'): price[idx][jdx] = -1 return price[goal[0]][goal[1]] n = int(raw_input().strip()) # your code goes here for a in xrange(1, n): for b in xrange(1, n): print distance(n, (0,0), (n-1,n-1), (a,b)), print