#!/usr/bin/env python3
import sys, random


def next_index(a, x, m):
    mini = -1
    maxi = m
    while(mini+1!=maxi):
        mid = (mini+maxi)//2
        if (a[mid][-1] > x):
            maxi =mid
        else:
            mini = mid
    return mini

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', MAXN))
mode = cmdlinearg('mode', '')
M = int(cmdlinearg('M', random.randint(1, min(MAXM, N))))

print(N, M)

if (mode == "alloccur"): 
    M -= 1

order = list(range(N))
random.shuffle(order)

a = [[] for _ in range (M+1)]

a[0].append(-1)

for i in range(M):
    a[i+1].append(order[i])
a.sort()

if mode == "alloccur":
    a[0][0] = order.pop()
    a.sort()

for i in range(M, len(order)):
    ind = next_index(a, order[i], M+1)
    if (ind == -1):
        ind = 0
    a[ind].append(order[i])

if (mode == "alloccur"):
    a[0].sort()
    random.shuffle(a)
else:
    tail = a[1:]
    random.shuffle(tail)
    a[1:] = tail

start = 1

if (mode == "alloccur"):
    start = 0

for i in range(start, M+1):
    who = [a[i][j] for j in range(-1, len(a[i]))]
    who[0] = len(a[i])
    print(" ".join(str(x) for x in who))
