Search in Lex Fridman’s podcasts

Lex Fridman hosts a very interesting podcast where he calls different guests like Elon Musk, Joe Rogan, Andrej Karpathy, and Vitalik Buterin to name a few. Both you and your friend Anna really enjoy watching the podcasts. When discussing the podcasts, you like talking about the number of views the podcast got and who was the guest. You’ve decided to write that information out and keep it as a list of pairs (guest, views). Now whenever Anna mentions a name of a guest, you can look at the list and find out the number of views that podcast got.
notion image
Can you write a program that would print the number of views for all the guests Anna was talking about?

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) - the number of podcasts you’ve kept as a list of pairs.
The next 2n lines contain pairs of guests and views. First comes the name of the guest, then the number of views that the podcast obtained.
The following line contains a single integer q (1 ≤ q ≤ n) - the number of questions Anna has about the podcast guests.
The next q lines are the names of the guests Anna talks about.

Output

For each of the q questions, the program should print the number of views the podcast obtained.

Examples

Input
Output
5 Elon Musk 6400000 Joe Rogan 6200000 Kanye West 4000000 Vitalik Buterin 4500000 Mark Zuckerberg 3800000 3 Elon Musk Mark Zuckerberg Joe Rogan
6400000 3800000 6200000
Disclaimer: This method of searching for the right answer is called a linear search. We’ll learn how to perform faster queries for different types of problems in a bit.
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in