Rough Week


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

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 n (1 \le n \le 10^5) - the number of drinks Jake likes.

The second line contains n distinct space-separated strings - Jake's preferred drinks.

The third line contains an integer p (1 \le p \le 2 \times 10^5) - the number of drink-to-pub mappings.

The next p lines each contain two space-separated strings c and d:

  • c is the pub name
  • d is a drink that pub serves

  • The total length of all strings does not exceed 3 * 10^5

  • All strings consist only of lowercase English letters and the underscore character (_) ## Output Output a single string representing the name of the best pub, or none if 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

There are no comments at the moment.