from ast import Store from heapq import heappush,heappop N = int(input()) q = [] ans = [] for i in range(1,2*N): heappush(q,(-i,i)) while q: S = [] store = [] n = N while n: t,s = heappop(q) t*=-1 n-=1 store.append((t,s)) S.append(s) for t,s in store: if t == 1: pass else: heappush(q,(-(t-1),s)) store = [] ans.append(S) S = [] print(len(ans)) for s in ans: print(*s)