from itertools import cycle N = int(input()) a = [[1]*(N+2)] + [[1]+[0]*N+[1] for _ in [0]*N] + [[1]*(N+2)] direction = cycle(((1, 0), (0, 1), (-1, 0), (0, -1))) x, y, dirx, diry = 1, 1, 0, 0 for i in range(1, N**2+1): if a[y+diry][x+dirx] != 0: dirx, diry = next(direction) x, y = x+dirx, y+diry a[y][x] = "{:03d}".format(i) for l in a[1:-1]: print(" ".join(l[1:-1]))