def n_dire(): dire = 0 while True: yield dire dire = (dire + 1) % 4 N = int(input()) nums = [[0 for x in range(N)] for y in range(N)] nd = n_dire() turn = False n = N ** 2 c = 1 x = -1 y = 0 step = N while c <= n: dire = next(nd) for i in range(step): if dire % 2: if dire == 1: y+=1 elif dire == 3: y-=1 else: if dire == 0: x+=1 elif dire == 2: x-=1 nums[y][x] = c c+=1 turn^=True if turn: step-=1 for i in nums: print(" ".join(map(lambda x:format(x,"03d"),i)))