import sys #input = sys.stdin.readline #文字列につけてはダメ input = sys.stdin.buffer.readline #文字列につけてはダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict from collections import defaultdict, deque import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] def main(): N = int(input()) M = 2*N - 1 G = [set([]) for _ in range(M)] A = [] for i in range(1,M+1): A.extend([i for _ in range(i)]) #print(A) idx = 0 while idx < M*(N-1): i = idx % M temp = A.pop() G[i].add(temp) idx += 1 #print(G) dic = defaultdict(int) mx = 0 for a in A: dic[a] += 1 mx = max(mx, a) #print(ans) num = 0 val = 0 while num < M: val += 1 num += val amari = num - M #print(amari) #print(num,val) ans = [] idx = M-1 while True: for i in reversed(range(val)): if amari <= 0: break t = copy.copy(G[idx]) t.add(i) dic[i] -= 1 nt = tuple(t) ans.append(nt) amari -= 1 idx -= 1 break #print("mid",ans) used = defaultdict(int) while idx >= 0: for i in reversed(range(1,mx+1)): #print("i",i,"dici",dic[i]) if dic[i] == 0: continue t = copy.copy(G[idx]) #print("T",t) t.add(i) nt = tuple(t) if used[nt] >= 2: continue used[nt] += 1 ans.append(nt) dic[i] -= 1 #print(nt) break idx -= 1 print(len(ans)) for ret in ans: print(*ret) if __name__ == '__main__': main()