N = int(input()) l = [[0] * N for i in range(N)] d = 0 print(l) x = 0 y = 0 for i in range(1, N**2 + 1): if d % 4 == 0: l[x][y] = str(i).zfill(3) y += 1 if y >= N or l[x][y] != 0: d += 1 y -= 1 x += 1 elif d % 4 == 1: l[x][y] = str(i).zfill(3) x += 1 if x >= N or l[x][y] != 0: d += 1 x -= 1 y -= 1 elif d % 4 == 2: l[x][y] = str(i).zfill(3) y -= 1 if y < 0 or l[x][y] != 0: d += 1 y += 1 x -= 1 elif d % 4 == 3: l[x][y] = str(i).zfill(3) x -= 1 if l[x][y] != 0: d += 1 x += 1 y += 1 ans = "" for i in l: ans = "" for j in i: ans += j ans += " " print(ans)