#!/bin/python import sys n = int(raw_input().strip()) # your code goes here def knight_moves(n,pair): (i,j) = pair moves = 1 visited = {(0,0)} new = {(i,j), (j,i)} directions = [(i,j),(j,i),(-i,j),(j,-i),(i,-j),(-j,i),(-i,-j),(-j,-i)] while len(new) > 0: if (n-1,n-1) in new: return moves moves += 1 visited.update(new) trythese = set() for (k,l) in new: trythese |= {(k+p,l+q) for (p,q) in directions} new = set() for (k,l) in trythese: if (k,l) == (n-1,n-1): return moves if k >= 0 and l >= 0 and k < n and l < n: new.add((k,l)) new -= visited return -1 steps = []*(n-1) for i in range(n-1): row = [] for j in range(n-1): if i <= j: row.append(knight_moves(n,(i+1,j+1))) elif i > j: row.append(steps[j][i]) steps.append(row) for row in steps: s = '' for num in row: s += '%d ' % num print(s[:-1])