def extract_arguments(fh):
    datasets = []
    while True:
        N = int(fh.readline().strip())
        if N == 0:
            break
        pw = int(fh.readline().strip())
        flowers = []
        for _ in range(N):
            vw, pf, vf, th = map(int, fh.readline().strip().split())
            flowers.append((vw, pf, vf, th))
        datasets.append((N, pw, flowers))
    return datasets