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() import copy for i in range (0, 2*N-1): c = 0 s= "".join(p[i]) while c == 0: q = d.popleft() u = str(q) s+=u if s not in mate: if s not in ikkai: ikkai.add(s) else: mate.add(s) c = 1 p[i].append(q) else: s = s[:-1] d.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)