import sys input = sys.stdin.readline N=int(input()) ANS=[[0]*N for i in range(2*N-1)] for i in range(N): x=i y=2*N-1-x if i%2==0: for j in range(x): ANS[j][i]=x for j in range(y): ANS[2*N-2-j][i]=y else: for j in range(y): ANS[j][i]=y for j in range(x): ANS[2*N-2-j][i]=x print(len(ANS)) for x in ANS: print(*x)