Nowadays, the systems in mobile phones are very user friendly. There is a shortcut button labelled Favourite for the most frequent dialed phone number so that you can make a phone call to that friend in a very short amount of time. The cellphone is smart enough to update the button dynamically.
Your job is to determine which phone number should be stored as the Favourite.
Input Specification
The input consists of two parts. The first part is the phone book showing the name of friends and their phone numbers. The second part is the phone numbers that have been dialed. The first integer in the input represents the total number of records in the phone book. Then each of the records follows on its own line. Each record starts with a name with no more than 20 characters (without any whitespace) and then a phone number with exactly 8 digits. Next, another integer in the input represents the total number of phone numbers that have been dialed. Finally, these phone numbers are listed, one per line.
Output Specification
For the most frequently dialed phone number, output the corresponding name. If there are two such numbers, output the one with the smaller phone number (where smaller mean numerically less than).
Sample Input
5
Mary 26000404
Susan 92132122
May 21232132
Ann 62343244
Peter 21321322
8
92132122
62343244
62343244
26000404
21321322
21232132
62343244
92132122
Sample Output
Ann
Comments
chinese computing competition
What is the HK supposed to mean in CCCHK?
Hong Kong
But doesn't CCC stand for Canadian Computing Contest? So it would be Canadian Computing Contest Hong Kong? Sorry, I'm not aware of any other meanings of CCC, I apologize if this question is stupid.
will the first digit of the phone number ever be 0?
This comment is hidden due to too much negative feedback. Show it anyway.