Send Balloon

Time Limit
1s
Memory Limit
32768KB
Judge Program
Standard
Ratio(Solve/Submit)
80.56%(29/36)
Description:

Welcome to Zhejiang Gongshang University's annual acm school competition !
In the live competition, each problem has a balloon of corresponding color. Look up at the blackboard to see the color corresponding to the problem number!
Then! Here comes the point! Every time solve a problem can get a balloon of corresponding color sent by the volunteer younger sister (little brother)!
Now it is up to you to check the accepted records and tell the volunteers what color balloons to take.

Input:

First line contains two positive integers, the number of problems n (n <= 15) and the number of participants m (m <= 500).

Next n lines, each line contains a lowercase word s (| s | <= 20) means the color corresponds to the problem number (starting from 0).

Next line contains the number of accepted records t(0 <= t <= 2000). Next t lines, each line contains two integers, the participant's id x (0 <= x < m), the AC problem number y(index from 0 to n-1) in record.

Output:

Output t lines, for each line containing a lowercase word s for balloon colors to each accepted record in order.

Sample Input:
5 200
blue
red
green
yellow
black
2
60 2
155 3
Sample Output:
green
yellow

Submit