from collections import deque def _neighbor(a, b, pos): x, y = pos for i in [-a, a]: for j in [-b, b]: yield (x + i, y + j) yield (x + j, y + i) def inbounds(pos, n): x, y = pos return 0 <= x < n and 0 <= y < n def neighbor(a, b, pos, n): for newpos in _neighbor(a, b, pos): if inbounds(newpos, n): yield newpos def find_path_length(a, b, n): q = deque() parent_of = dict() q.append((0, 0)) while q: v = q.popleft() if v == (n - 1, n - 1): break for u in neighbor(a, b, v, n): if u not in parent_of: parent_of[u] = v q.append(u) length = -1 v = (n - 1, n - 1) while v != (0, 0) and v in parent_of: length += 1 v = parent_of[v] return length + 1 if length != -1 else -1 def solve(): n = int(input()) out = [[0]*n for i in range(n)] for a in range(1, n): for b in range(a, n): out[a][b] = find_path_length(a, b, n) out[b][a] = out[a][b] for a in range(1, n): for b in range(1, n): print(out[a][b], end=' ') print() solve()