N = int(input()) cnt = (2 * N - 1) ans = [[0] * N for i in range(2 * N - 1)] for i in range(2 * N - 1, N, -1): d = 2 * N - 1 - i for x in range(0, i): ans[x][d] = i for x in range(N): ans[x][-1] = x + 1 for x in range(2 * N - 1): for y in range(N): if ans[x][y] == 0: v = abs(x - 2 * N + 1) + abs(y - N) ans[x][y] = v print(2 * N - 1) for i in range(2 * N - 1): print(*ans[i])