#!/bin/python3 import sys def valid_move_combine(start, dpos, n): end = (start[0]+dpos[0], start[1]+dpos[1]) if end[0] >= 0 and end[0] < n and end[1] >= 0 and end[1] < n: return end else: return None def KnightL(a,b,n): halfMoves = [(a,b),(-a,b),(a,-b),(-a,-b)] moves = halfMoves + [(y,x) for (x,y) in halfMoves] moves = set(moves) Q = [] start = (0,0) end = (n-1,n-1) Q.append([start]) visited = set() while Q: path = Q.pop(0) node = path[-1] if node == end: return path if node not in visited: visited.add(node) for dpos in moves: adj = valid_move_combine(node, dpos, n) if adj: Q.append(path+[adj]) return None n = int(input().strip()) for a in range(1,n): res = [] for b in range(1,n): temp = KnightL(a,b,n) #print(temp) if temp: res.append(len(temp)-1) else: res.append(-1) print(*res, sep=' ')