def minDistance(i, j, n): queue = [] visited = {} queue.append((0, 0, 0)) while(queue): node = queue.pop(0) a, b, moves = node # add node to visited list if (a,b) in visited: continue # break if we are out of bounds if a < 0 or a >= n or b < 0 or b >= n: continue if a == n-1 and b == n-1: return node[2] queue.append((a + i, b + j, moves + 1)) queue.append((a - i, b + j, moves + 1)) queue.append((a + i, b - j, moves + 1)) queue.append((a - i, b - j, moves + 1)) queue.append((a + j, b + i, moves + 1)) queue.append((a - j, b + i, moves + 1)) queue.append((a + j, b - i, moves + 1)) queue.append((a - j, b - i, moves + 1)) visited[(a, b)] = True return -1 # print minDistance(3, 3, 5) n = int(raw_input()) for a in xrange(1, n): output = "" for b in xrange(1, n): output += " " + str(minDistance(a, b, n)) print output.strip()