N = int(input()) M = 2 * N - 1 L = [i for i in range(1,M+1)] print(M) K = [i for i in range(M,M-N,-1)] cnt = 0 for c in range(M): print(*K) if c == M - 1: break for i in range(N): L[K[i]-1] -= 1 P = list(K) for i in range(N): while L[P[i]-1] == 0: P[i] -= 1 if i < N - 1 and P[i+1] == P[i]: P[i+1] = P[i] - 1 if K == P: cnt += 1 if cnt == 2: P[-1] -= 1 while L[P[-1]-1] == 0: P[-1] -= 1 cnt = 0 else: cnt = 0 K = list(P)