#python3

import sys

n = int(sys.argv[1])

l = 1
iter = 0
perf = []
while l < n:
    new_perf = []
    for i in range(n):
        if i // l % 2 == iter:
            new_perf.append(i)
    perf.append(new_perf)
    l *= 2
    iter = 1 - iter

p = list(range(n))
MOD = 21983917
seed = n * 79
for i in range(len(p)):
    seed = (seed * 17 + 13) % MOD
    idx = seed % (i + 1)
    p[i] = p[idx]
    p[idx] = i

print(n, len(perf))
for cperf in perf:
    print(len(cperf), " ".join(str(p[x] + 1) for x in cperf))

