#!/usr/bin/env python3
"""
YES instance: a long monotone chain on one table, singleton stacks elsewhere.

  chain table : [0, 1, ..., N-M]      (length N-M+1)
  others (M-1): [N-M+i]                (singleton each)

Trace (with chain at the table that receives baker 0):
  First M bakers go to tables in arrival order. We pick an arrival order in
  which baker 0 lands on the chain table and bakers N-M+1, ..., N-1 land on
  the other M-1 tables (one each). After that, bakers 1, 2, ..., N-M arrive;
  each finds the chain table holding its predecessor (the only table holding
  a rank < their own, since the singletons are all >= N-M+1) and stacks onto
  it in order. Sum of stack lengths = N (alloccur), so this is valid under
  MODE="all".
"""

import sys, random


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))
M = int(cmdlinearg("M", min(MAXM, max(2, N // 3))))

assert M >= 2, f"need M >= 2, got {M}"
assert N >= M + 1, f"need N >= M+1, got N={N} M={M}"

stacks = [list(range(N - M + 1))]
for i in range(1, M):
    stacks.append([N - M + i])

random.shuffle(stacks)

print(N, M)
for s in stacks:
    print(len(s), *s)
