def extract_arguments(fh):
    test_cases = []
    while True:
        M, N = map(int, fh.readline().strip().split())
        if M == 0 and N == 0:
            break
        delays = list(map(int, fh.readline().strip().split()))
        problems = []
        for _ in range(N):
            L = int(fh.readline().strip())
            submissions = []
            for _ in range(L):
                P, T, A = fh.readline().strip().split()
                P = int(P)
                T = int(T)
                submissions.append((P, T, A))
            problems.append(submissions)
        test_cases.append((M, N, delays, problems))
    return test_cases

# Example usage:
# if __name__ == "__main__":
#     input_path = sys.argv[1]
#     with open(input_path, 'r') as fh: 
#         test_cases = extract_arguments(fh)
#         for case in test_cases:
#             f(case)