The most frequent element P66257


Statement
 

pdf   zip

html

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 109. Suppose that every n is between 0 and 105, 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.

Public test cases
  • Input

    3   0 4 6
    4   2 3 4 5
    
    4   10 20 30 40
    3   10 10 30
    
    6   10 10 12 20 20 20
    8   6 6 6 10 12 12 25 25
    
    0
    1   1000000000
    
    4   42 800000000 800000000 1000000000
    0
    

    Output

    4 2
    10 3
    20 3
    1000000000 1
    800000000 2
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C++ Python