N = int(input().strip()) a = [[0 for _ in range(N)] for _ in range(N)] lst = [(1, 0), (0, 1), (-1, 0), (0, -1)] cnt = 1 idx = 0 #b = lst[0] x, y = 0, 0 x_tmp, y_tmp = 0, 0 while True: if cnt > N**2: break if a[y_tmp % N][x_tmp % N] > 0: idx += 1 else: a[y_tmp][x_tmp] = cnt cnt += 1 x, y = x_tmp, y_tmp x_tmp, y_tmp = x + lst[idx % len(lst)][0], y + lst[idx % len(lst)][1] for y in range(N): print(' '.join(['{:03d}'.format(a[y][i]) for i in range(N)]))