from random import *
import os
from time import sleep
from subprocess import *


def gen():
    r = lambda x: randint(1, x)
    with open("input.txt", "w") as f:
        f.write("1\n")
        n = 20
        k = randint(1, n)
        f.write(f"{n} {k}\n")
        for _ in range(n):
            f.write(f"{r(k)} {r(100)} {r(100)} {r(100)} {r(100)}\n")


while True:
    gen()
    a = run("./1010 < input.txt", shell=True,
            stdout=PIPE).stdout.decode().strip()
    b = run("./1010_f2 < input.txt", shell=True,
            stdout=PIPE).stdout.decode().strip()
    print(a, b)
    if a != b:
        break