#!/bin/python import sys n = int(raw_input().strip()) # your code goes here jumps = [] def jumper(curr, inc): pos1 = [curr[0] + inc[0], curr[1] + inc[1]] pos2 = [curr[0] + inc[1], curr[1] + inc[0]] pos3 = [curr[0] - inc[0], curr[1] + inc[1]] pos4 = [curr[0] - inc[1], curr[1] + inc[0]] pos5 = [curr[0] + inc[1], curr[1] - inc[0]] pos6 = [curr[0] + inc[0], curr[1] - inc[1]] pos7 = [curr[0] - inc[1], curr[1] - inc[0]] pos8 = [curr[0] - inc[0], curr[1] - inc[1]] return pos1, pos2, pos3, pos4, pos5,pos6,pos7,pos8 for x in range (1, n): jumps.append([-1 for i in range(n-1)]) for y in range(1, n): start = [0, 0] past_positions = [[0, 0]] end = [n-1, n-1] inc = [x, y] jump = 0 madeit = False next_ps = jumper(start, inc) while madeit == False: jump += 1 positions = [] #print next_ps #print past_positions for next_p in next_ps: if cmp(next_p, end) == 0: past_positions.append(next_p) madeit = True break else: if next_p[0] >= 0 and next_p[1] >= 0 and (next_p[0] <= (n-1)) and (next_p[1] <= (n-1)): if next_p not in past_positions: positions.append(next_p) #print past_positions #print positions #print past_positions if madeit == False: if len(positions) == 0: break next_ps = () for p in positions: #print p if p not in past_positions: past_positions.append(p) next_ps = next_ps + jumper(p, inc) #print next_ps if madeit: jumps[x-1][y-1] = jump for j in jumps: print ' '.join(map(str, j))