#!/bin/python import sys def findChildOne(curr, a, b): res = [] if curr[0]+a < n and curr[1]+b < n: res.append((curr[0]+a, curr[1]+b, curr[2]+1)) if curr[0]+a < n and curr[1]-b >= 0: res.append((curr[0]+a, curr[1]-b, curr[2]+1)) if curr[0]-a >= 0 and curr[1]+b < n: res.append((curr[0]-a, curr[1]+b, curr[2]+1)) if curr[0]-a >= 0 and curr[1]-b >= 0: res.append((curr[0]-a, curr[1]-b, curr[2]+1)) #print 'findChildOne', res return res def findChild(curr, a, b): res = [] res = findChildOne(curr, a, b) if a != b: res.extend(findChildOne(curr, b, a)) #print res return res def BFS(a, b, n): q, visited = [(0, 0, 0)], [] curr = q[0] while q: #print q, visited curr = q[0] q.pop(0) if curr[0] == n-1 and curr[1] == n-1: #print curr[2] return curr[2] if (curr[0], curr[1]) in visited: #print 'Already there' continue visited.append((curr[0], curr[1])) #print 'Find Children' child = findChild(curr, a, b) #print 'Found Children' q.extend(child) return -1 n = int(raw_input().strip()) a = [] for _ in xrange(n-1): a.append([0]*(n-1)) # your code goes here for i in range(1, n): for j in range(i, n): r = BFS(i, j, n) #print i, j, r a[i-1][j-1] = r a[j-1][i-1] = r #print a #print a for i in a: for j in i: print j, print ''