The most frequent element

Given two sequences of numbers, each sorted nondecreasingly, compute which number occurs more times in total in both sequences, and how many times it occurs.

Input

Input consists of several cases, each one with two sequences sorted in nondecreasing order. Every sequence starts with its number of items nn, followed by the nn elements, all between 0 and 10910^9. Suppose that every nn is between 0 and 10510^5, and that at least one of the two sequences is not empty.

Output

For every case, print which number occurs more times (the largest in the event of a tie), and how many times it occurs.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:28:12.381Z

© Jutge.org, 2006–2026.
https://jutge.org