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 n,
followed by the n elements, all between 0 and 10⁹. Suppose that every n
is between 0 and 10⁵, 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
