Marathoner (Marathon Runner)
Bobby is passionate about marathon running. Not only does he participate himself, but he has also inspired K of his friends to join a marathon event. To encourage them to train and compete earnestly, Bobby has promised rewards: any friend who completes the marathon in under 6 hours will receive a prize. Additionally, the friend with the fastest time under 6 hours will earn an extra special prize. On race day, Bobby noted down the runner numbers of his friends before they all started. However, after the race, his friends were too tired to report their times, whether they finished or not. So, Bobby went to the race office to get the official times for his friends. The challenge was that the records were not sorted by runner number or time, making it difficult to find the information for all K friends among N total runners. Observing this, you realized that with the help of a computer, identifying how many of Bobby's friends finished within 6 hours and who had the best time was straightforward. You decided to write a simple program to solve this problem. Below are the input and output specifications for your program:
Input
The first line contains a positive integer T, representing the number of test cases, where T ≤ 10. Each test case includes the following:
\begin{enumerate}\item The first line contains a positive integer K (1 < K ≤ 100).
\item The second line lists the runner numbers of Bobby's K friends, each a positive integer not exceeding 1,000,000, separated by spaces.
\item The third line contains a positive integer N (K < N ≤ 1,000).
\item The next N lines provide details for each runner, one per line. Each line consists of three integers: the runner's ID (a positive integer not exceeding 1,000,000), and the hours and minutes taken to finish the race. The minutes are a non-negative integer not exceeding 59, and the hours are a non-negative integer not exceeding 23. If a runner dropped out, both numbers will be -1.
\end{enumerate}
Output
The output consists of T lines, one for each test case. For each test case, output two numbers separated by a single space:
\begin{enumerate}\item The first number is the runner ID of Bobby's friend with the best time.
\item The second number is the count of Bobby's friends who finished the race within 6 hours (the maximum time to qualify for a prize is 6 hours 0 minutes).
\end{enumerate}
Note: The input guarantees that at least one of Bobby's friends finishes within 6 hours, and there is only one friend with the best time. Runner IDs are unique.