Time limit
2s
Memory limit
256 MB
Dasom is preparing for a test on a Pokemon encyclopedia. The encyclopedia lists Pokemon names in order from number 1 through number N.
Then M queries are given. If a query consists only of digits, print the Pokemon name with that number. If a query consists only of letters, print the number assigned to that name.
The first line contains two natural numbers N and M: the number of Pokemon in the encyclopedia and the number of queries. Both N and M are between 1 and 100,000, inclusive.
The next N lines contain the names of Pokemon number 1 through number N, one per line and in order. Each name consists only of English letters and has length between 2 and 20, inclusive. The first character is uppercase and the remaining characters are lowercase, although some names may have only their last character uppercase as well.
The following M lines each contain one query. A digit-only query is a number between 1 and N, inclusive. A letter-only query is guaranteed to be a Pokemon name in the encyclopedia.
For each query, print one answer on its own line. If the query is a number, print the corresponding Pokemon name. If the query is a name, print the corresponding number.