def bfs(i, j): dist = {} start = 0, 0 goal = n-1, n-1 queue = [start] dist[start] = 0 while len(queue): cur = queue[0] queue.pop(0) if cur == goal: return dist[cur] for move in [(i, j), (j, i), (-i, -j), (-j, -i), (i, -j), (-i, j), (-j, i), (j, -i)]: next_pos = cur[0] + move[0], cur[1] + move[1] if next_pos[0] > goal[0] or next_pos[1] > goal[1] or next_pos[0] < 0 or next_pos[1] < 0: continue if next_pos not in dist: dist[next_pos] = dist[cur]+1 queue.append(next_pos) return -1 n = int(input().strip()) ans = [] for i in range(1, n): ans.append([]) for j in range(i, n): ans[-1].extend([bfs(i, j)]) print(' '.join(str(p) for p in ans[0])) for i in range(1, n-1): ans[i] = [ans[j][i] for j in range(i)]+ans[i] print(' '.join(str(p) for p in ans[i]))