#include <iostream>
#include <string>
#include <map>
using namespace std;
map<int, string> pNumName;
map<string, int> pNameNum;
int num;
string name;
int question;
string input;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> num;
cin >> question;
for (int i=1; i < num+1; i++)
{
cin >> name;
pNumName.insert({i, name});
pNameNum.insert({name, i});
}
for (int i=0; i < question; i++)
{
cin >> input;
if (isdigit(input[0]))
{
cout << pNumName.at(stoi(input)) << "\n";
}
else
{
cout << pNameNum.at(input) << "\n";
}
}
}
map의 value로 key를 찾는 게 번잡하기 때문에