#!/usr/bin/env python3

import sys
import random
import 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

def gen(n, m, w, start, mode):
    if start == -1:
        start = random.randint(0, m - w)
    if mode == "random":
        return random.sample(range(start, start + w), n)
    if mode == "random_outlier":
        l = random.sample(range(start, start + w), n)
        l[-1] = random.randint(0, m-10)
        return l
    if mode == "consecutive":
        return [start + i for i in range(n)]
    if mode == "spaced":
        return [start + i*w for i in range(n)]
    raise Exception(f"bad mode: {mode}")

def main():
    random.seed(int(cmdlinearg("seed", sys.argv[-1])))
    nlo = int(cmdlinearg("nlo", 1))
    limn = int(cmdlinearg("n"))
    m = int(cmdlinearg("m"))
    w = int(cmdlinearg("w", m))
    start = int(cmdlinearg("start", -1))
    sumn = int(cmdlinearg("sumn", 100))
    mode = cmdlinearg("mode")
    cursum = 0
    tcs = []
    while cursum < sumn:
        if mode == "random" or mode == "random_outlier" or mode == "spaced":
            n = random.randint(nlo, limn)
        if mode == "consecutive":
            n = nlo + len(tcs)
        n = min(n, sumn - cursum)
        cursum += n
        tcs.append(gen(n, m, w, start, mode))
    assert cursum == sumn
    print(m, int(cmdlinearg("maxwrite", 1)))
    print(len(tcs))
    for tc in tcs:
        print(len(tc))
        print(*tc)

main()
