#!/bin/python3 from copy import copy import sys n = int(input().strip()) for i in range(1,n): for j in range(1,n): # initial cell cells = set() cells.add(0) moves = 0 while n**2-1 not in cells: old_cells = copy(cells) new_cells = set() for c in cells: # add all possible cells if 0 <= c%n + j < n and 0 <= c//n + i < n: new_cells.add(c + i*n + j) if 0 <= c%n - j < n and 0 <= c//n + i < n: new_cells.add(c + i*n - j) if 0 <= c%n + j < n and 0 <= c//n - i < n: new_cells.add(c - i*n + j) if 0 <= c%n - j < n and 0 <= c//n - i < n: new_cells.add(c - i*n - j) if 0 <= c%n + i < n and 0 <= c//n + j < n: new_cells.add(c + i + j*n) if 0 <= c%n + i < n and 0 <= c//n - j < n: new_cells.add(c + i - j*n) if 0 <= c%n - i < n and 0 <= c//n + j < n: new_cells.add(c - i + j*n) if 0 <= c%n - i < n and 0 <= c//n - j < n: new_cells.add(c - i - j*n) #print(new_cells) cells = cells.union(new_cells) #print(cells) # stop if no new cells added if cells == old_cells: moves = -1 break moves += 1 print(moves, end = ' ') print()