import sys input = sys.stdin.readline from collections import Counter N=int(input()) ANS=[[0]*N for i in range(2*N-1)] r=0 c=0 for i in range(1,2*N): for j in range(i): ANS[r][c]=i r+=1 if r==2*N-1: r=0 c+=1 C=Counter() for x in ANS: C[tuple(x)]+=1 ANS=[] for x in C: if C[x]==1: ANS.append(x) else: ANS.append(x) ANS.append(x) print(len(ANS)) for x in ANS: print(*x)