n = int(input()) r = [[] for _ in range(n)] W = 2*n-1 for i in range(n-1): v = W-i r[i].extend([v]*v) r[i].extend([W-v+2]*(W-v)) for i in range(3,W-v+3): r[-1].extend([i]*2) r[-1].extend([2,2,1]) print(W) for lst in zip(*r): print(*lst)