N = int(input()) ans = [[-1] * N for _ in range(N)] x, y = 0, 0 dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] def f(s): return "0" * (3 - len(str(s))) + str(s) k = 0 for i in range(N*N): ans[x][y] = f(i + 1) nx, ny = x + dx[k], y + dy[k] if nx < 0 or nx > N - 1 or ny < 0 or ny > N - 1: k = (k + 1) % 4 elif ans[nx][ny] != -1: k = (k + 1) % 4 x, y = x + dx[k], y + dy[k] for a in ans: print(*a)