#!/bin/python import sys def is_valid_coord((x, y)): return bool(x >= 0 and x<= n-1 and y >= 0 and y<= n-1) def get_new_coordinates(a, b, pos, coordinates): op = [(a, b), (-a, b), (a, -b), (-a, -b), (b, a), (-b, a), (b, -a), (-b, -a)] new_coordinates = set() for delta in op: new_pos = (pos[0]+delta[0], pos[1]+delta[1]) if is_valid_coord(new_pos) and new_pos not in coordinates: new_coordinates.add(new_pos) return new_coordinates def reach_point(i, j, coordinates, mpos=[(0, 0)], step=1): new_coordinates = set() for pos in mpos: new_coordinates.update(get_new_coordinates(i, j, pos, coordinates)) if not new_coordinates: return -1 for coord in new_coordinates: if coord == (n-1, n-1): return step coordinates.update(new_coordinates) return reach_point(i, j, coordinates, new_coordinates, step+1) n = int(raw_input().strip()) m = [[-1 for y in range(n-1)] for x in range(n-1)] # your code goes here for i in range(1, n): for j in range(i, n): coordinates = set() m[i-1][j-1] = str(reach_point(i, j, coordinates)) m[j-1][i-1] = m[i-1][j-1] for i in range(n-1): print ' '.join(m[i])