from __future__ import print_function import heapq n = int(raw_input()) def move(pos): table = [[float('inf')for i in range(n)] for j in range(n)] pq = [(0,0,0)] while len(pq): steps, x, y = heapq.heappop(pq) for (a,b) in pos: if not(0 <= x+a < n and 0 <= y + b < n): continue if steps + 1 < table[x+a][y+b]: table[x+a][y+b] = steps + 1 heapq.heappush(pq, (steps + 1, x+a, y+b)) return table[n-1][n-1] for i in range(1,n): line = [] for j in range(1,n): pos = [ (i,j), (-i,-j), (-i,j), (i,-j), (j,i), (-j,-i), (-j,i), (j,-i) ] res = move(pos) if res == float('inf'): line.append(-1) else: line.append(res) print(*line, sep=' ')