import sys input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x)) debug = lambda x: sys.stderr.write(x+"\n") YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO) LI = lambda : list(map(int, input().split())) sys.setrecursionlimit(3*10**5+10) n = int(input()) ans = [[0]*n for _ in range(2*n-1)] for i in range(n): for j in range(n+i): ans[j][i] = n+i for i in range(n): ans[i][0] = i+1 for i in range(n, 2*n-1): for j in range(2*n-1-i): ans[i+j][j] = 2*n-i print(len(ans)) for item in ans: write(" ".join(map(str, item)))