#!/bin/python3 def pos_moves(x,y,a,b,n): result=[] for xd,yd in ((a,b),(a,-b),(-a,b),(-a,-b),(b,a),(b,-a),(-b,a),(-b,-a)): if (not 0 <= x+xd < n) or (not 0 <= y+yd < n): continue result.append((x+xd,y+yd)) return result def moves(a,b,n): found=set() d={(0,0):0} todo=[(0,0)] goal=(n-1,n-1) while todo: p = todo.pop(0) d_p=d[p] for m in pos_moves(p[0],p[1],a,b,n): if m in found:continue elif m == goal:return d_p+1 else: found.add(m) d[m] = d_p+1 todo.append(m) return -1 n = int(input().strip()) for i in range(1,n): print(*[moves(i,j,n) for j in range(1,n)])