#include<map>
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
int x,y;
while(scanf("%d",&x)!=EOF)
{
getchar();
map<string,string>mymap;
while(x--!=0)
{
string str1;
string str2;
getline(cin,str1);
int pos=str1.find(" ");
str2=str1.substr(0,pos);
mymap[str2]=str1;
}
scanf("%d",&y);
while(y--!=0)
{
string key;
getchar();
getline(cin,key);
if(mymap.find(key)!=mymap.end())
{
printf("%s\n",mymap[key].c_str());
}else
{
printf("no answer\n");
}
}
}
return 0;
}