Rough Week
Jake has just finished his first week at AUCPL Inc., and let's just say he is glad it's over. To end this week of hell, he is going out for some drinks. Unfortunately, Jake has no friends, so he is hitting the town on his own. Being new in town, he is trying to find the best bar to go to.
Jake knows what drinks he likes, and he has collected information about what drinks different pubs serve. Jake wants to find the best pub to visit.
The definition of the best pub is: the pub that serves the highest total number of unique drinks from Jake's preference list. If there is a tie, output the pub whose name is lexicographically (i.e. alphabetically) smallest.
If no pub satisfies the requirements, output none.
Input
The first line contains an integer
- the number of drinks Jake likes.
The second line contains distinct space-separated strings - Jake's preferred drinks.
The third line contains an integer
- the number of drink-to-pub mappings.
The next lines each contain two space-separated strings
and
:
is the pub name
is a drink that pub serves
The total length of all strings does not exceed
- All strings consist only of lowercase English letters and the underscore character (
_) ## Output Output a single string representing the name of the best pub, ornoneif no pub satisfies the requirements.
Example
Input 1
3
milk beer vodka
4
the_lucky_capybara water
the_lucky_capybara beer
the_ritisha_emporium milk
the_lucky_capybara vodka
Output 1
the_lucky_capybara
the_lucky_capybara serves water, beer, and vodka. the_ritisha_emporium serves only milk. Thus, the_lucky_capybara has more drinks Jake likes (2 vs 1).
input 2
2
water milk
4
the_tavern ale
the_tavern cider
soda_shop juice
soda_shop soda
output 2
none
No pub serves a drink Jake likes so the result is none.
Comments