N = int(input()) print(2*N-1) p = [[str(2*N-1)] for i in range (0, 2*N-1)] if N == 1: print(1) exit() if N == 2: print('3 2') print('3 2') print('3 1') exit() import collections as col d = col.deque() for i in range (0, 2*N-2): q = 2*N-2-i for j in range (0, q): d.append(str(q)) for i in range (0, (N-2)*(2*N-1)): p[i%(2*N-1)].append(d.popleft()) ikkai = set() mate = set() for i in range (0, 2*N-1): c = 0 s= "".join(p[i]) while c == 0: q = d.popleft() if s+q in mate: d.append(s+q) else: if s+q in ikkai: mate.add(s+q) else: ikkai.add(s+q) c = 1 p[i].append(q) for i in range (0, len(p)): v = [] for j in range (0, len(p[i])): v.append(int(p[i][j])) print(*v)