#!/usr/bin/env python3
"""
YES instance with many walkers: every stack is a singleton, with ranks
drawn from the top of the rank range.

  M singleton stacks containing ranks {N-M, N-M+1, ..., N-1} (one each).
  Bakers with ranks 0, ..., N-M-1 all walk away.

Trace: arrange the arrival of the M placed bakers in any order (their
arrival index determines which table they fill). Then the remaining
bakers arrive in any order; each finds every table holds a rank
> their own and walks away.

Output sum of stack lengths = M < N, so this requires the subtask to
allow walkers (MODE != "all"). Useful for exercising the "every unplaced
rank must be < smallest stack top" check.
"""

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 // 10))))

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

placed = list(range(N - M, N))
random.shuffle(placed)

print(N, M)
for r in placed:
    print(1, r)
