import heapq n = int(input()) a = [] for i in range(1, 2 * n): a.append((-i, i)) heapq.heapify(a) print(2 * n - 1) for i in range(2 * n - 1): res = [] his = [] for j in range(n): p = heapq.heappop(a) res.append(p[1]) his.append(p) for p in his: heapq.heappush(a, (p[0] + 1, p[1])) print(*res)