#!/bin/python3 import sys def make_act_set(a, b): actset = [] actset.append([a, b]) actset.append([-a, b]) actset.append([a, -b]) actset.append([-a, -b]) actset.append([b, a]) actset.append([-b, a]) actset.append([b, -a]) actset.append([-b, -a]) return actset def make_xy_set(N): xyset = [] for x in range(N): for y in range(N): xyset.append([x, y]) xyset.remove([0, 0]) return xyset def take_step(cur_xy_list, actset, xyset, N): new_xy_list = [] for curxy in cur_xy_list: for act in actset: new_xy = [i for i in curxy] new_xy[0] += act[0] new_xy[1] += act[1] if new_xy in xyset: new_xy_list.append(new_xy) xyset.remove(new_xy) if not [N-1, N-1] in xyset: break return new_xy_list, xyset def find_sol(N, index_pair): xyset = make_xy_set(N) actset = make_act_set(index_pair[0], index_pair[1]) step = 0 cur_xy_list = [[0, 0]] while(1): cur_xy_list, xyset = take_step(cur_xy_list, actset, xyset, N) step += 1 if len(cur_xy_list) == 0: step = -1 break elif not [N-1, N-1] in xyset: break return step N = int(input().strip()) #find_sol(N, [1, 1]) # print(find_sol(N, [1, 1])) # print(find_sol(N, [1, 2])) # print(find_sol(N, [1, 3])) # print(find_sol(N, [1, 4])) sol = [] for loof in range(N-1): sol.append([0 for i in range(N-1)]) for row in range(N-1): for col in range(N-1): if row > col : sol[row][col] = sol[col][row] else: sol[row][col] = find_sol(N, [row+1, col+1]) for i in range(N-1): for j in range(N-1): if j < N-2: print(sol[i][j], end=' ') else: print(sol[i][j])