#!/usr/bin/env python3

# distributes numbers randomly to lists, drops numbers (the lower the number, the more likely it is dropped)
import sys, random, math

def cmdlinearg(name, default=None):
    for arg in sys.argv:
        if arg.startswith(name + "="):
            return arg.split("=")[1]
    assert default is not None, name
    return default

random.seed(int(cmdlinearg('seed', sys.argv[-1])))


MAXN = int(sys.argv[1])
MAXM = int(sys.argv[2])
N = int(cmdlinearg('N', random.randint(1, MAXN)))
M = int(cmdlinearg('M', random.randint(1, min(MAXM, N))))

print(N, M)

lists = [[] for i in range(M)]
for i in range(N):
    lists[random.choice(range(M))].append(i)

for l in lists:
    res = []
    for x in l:
        # i don't really know what this means but it does generate yes-instances
        if random.random() >= 1.0 / math.sqrt(x + 1):
            res.append(x)
    print(len(res), " ".join(str(x) for x in res))
