N = int(input()) ans = [['000' for _ in range(N)] for _ in range(N)] nx, ny, c, dx, dy = 0, 0, 1, 0, 1 for i in range(N * N): ans[nx][ny] = str(c).zfill(3) if 0 <= nx + dx < N and 0 <= ny + dy < N and ans[nx + dx][ny + dy] == '000': nx += dx ny += dy else: dx, dy = dy, -dx nx += dx ny += dy c += 1 for i in ans: print(*i)