The first line contains a positive integer , representing the number of test cases, where T \leq 10. Each test case includes the following:
The first line contains a positive integer (1 < K \leq 100).
The second line lists the runner numbers of Bobby's friends, each a positive integer not exceeding , separated by spaces.
The third line contains a positive integer (K < N \leq 1\,000).
The next lines provide details for each runner, one per line. Each line consists of three integers: the runner's ID (a positive integer not exceeding ), and the hours and minutes taken to finish the race. The minutes are a non-negative integer not exceeding , and the hours are a non-negative integer not exceeding . If a runner dropped out, both numbers will be .
The output consists of lines, one for each test case. For each test case, output two numbers separated by a single space:
The first number is the runner ID of Bobby's friend with the best time.
The second number is the count of Bobby's friends who finished the race within hours (the maximum time to qualify for a prize is hours minutes).
Example 1
The input guarantees that at least one of Bobby's friends finishes within hours, and there is only one friend with the best time. Runner IDs are unique.