#!/bin/python3 from copy import deepcopy import sys n = int(input().strip()) # your code goes here for i in range(1, n): for j in range(1, n): table = [[None for x in range(n)] for x in range(n)] table[0][0] = 0 step_num = 0 old_table = deepcopy(table) new_table = deepcopy(table) #print(i, j) while True: try: # perform step for k in range(n): for l in range(n): if old_table[k][l] != step_num: continue #print(str(k) + ' - ' + str(l)) new_x = k+i new_y = l+j if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 if new_x == n-1 and new_y == n-1: print(step_num+1, end=' ') raise ValueError new_x = k+j new_y = l+i if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 if new_x == n-1 and new_y == n-1: print(step_num+1, end=' ') raise ValueError new_x = k-i new_y = l+j if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 new_x = k+i new_y = l-j if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 new_x = k-i new_y = l-j if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 new_x = k-j new_y = l+i if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 new_x = k+j new_y = l-i if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 new_x = k-j new_y = l-i if not (new_x < 0 or new_y < 0 or new_x >=n or new_y >=n): if new_table[new_x][new_y] is None: new_table[new_x][new_y] = step_num+1 if old_table == new_table: print(str(-1), end=' ') raise ValueError #print(new_table) old_table = deepcopy(new_table) step_num += 1 except ValueError: break print()