#!/bin/python3 import sys def min_dist(n,a,b): start=(0,0) finish=(n-1,n-1) chessboard=dict() chessboard[start]=0 frontline=[start] while len(frontline): row,col=frontline.pop(0) next=[(row+r,col+c) for r in [-a,a] for c in [-b,b]] next.extend([(row+r,col+c) for r in [-b,b] for c in [-a,a]]) next=filter(lambda pt: all(coord>=0 and coordcurr_step: chessboard[pt]=curr_step frontline.append(pt) return chessboard[finish] if finish in chessboard else -1 n = int(input().strip()) answer=[[min_dist(n,a,b) for a in range(1,n)] for b in range(1,n)] for line in answer: print(*line)