#python3

import sys

num_groups, each_group, m, length = (int(x) for x in sys.argv[1:])
if m <= each_group:
    sys.stderr.write("m <= each :(")
    exit(1)

MOD = 192383197
seed = each_group * 17 + num_groups * 13 + m * 11 + length * 7
print(num_groups * each_group + 1, m)

out = [set() for x in range(m)]
man_number = 0
for group in range(num_groups):
    same_group = []
    for i in range(length - 1):
        seed = (seed * 17 + 13) % MOD
        same_group.append(seed % (m - each_group))

    same_group = list(set(same_group))
    same_group.sort()

    for i in range(each_group):
        man_number += 1
        for x in same_group:
            out[x].add(man_number)
        out[m - each_group + i].add(man_number)


man_number += 1
p = list(range(man_number))
for i in range(len(p)):
    seed = (seed * 17 + 13) % MOD
    idx = seed % (i + 1)
    p[i] = p[idx]
    p[idx] = i


for perf in out:
    if len(perf) == 0:
        print(1, p[man_number - 1] + 1)
    else:
        print(" ".join( (str(x) for x in [len(perf)] + [p[x - 1] + 1 for x in perf]) ))


