// include file
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <strstream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <functional>
using namespace std;
// typedef
typedef long long LL;
typedef unsigned long long ULL;
//
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define FORi(a,b,c) for(int i=(a);i<(b);i+=c)
#define FORj(a,b,c) for(int j=(a);j<(b);j+=c)
#define FORk(a,b,c) for(int k=(a);k<(b);k+=c)
#define FORp(a,b,c) for(int p=(a);p<(b);p+=c)
#define FF(i,a) for(int i=0;i<(a);i+++)
#define FFD(i,a) for(int i=(a)-1;i>=0;i--)
#define Z(a) (a<<1)
#define Y(a) (a>>1)
const double eps = 1e-6;
const double INFf = 1e10;
const int INFi = 1000000000;
const double Pi = acos(-1.0);
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T TMAX(T x,T y)
{
if(x>y) return x;
return y;
}
template<class T> inline T TMIN(T x,T y)
{
if(x<y) return x;
return y;
}
template<class T> inline void SWAP(T &x,T &y)
{
T t = x;
x = y;
y = t;
}
template<class T> inline T MMAX(T x,T y,T z)
{
return TMAX(TMAX(x,y),z);
}
// code begin
unsigned int BKDRHash(char *str)
{
unsigned int seed = 131;// 31 131 1313 13131 131313
unsigned int hash = 0;
while(*str)
{
hash = hash*seed + (*str++);
}
return (hash&0x7FFFFFFF);
}
struct node1
{
int next;
char eng[12];
char fri[12];
};
node1 mem[100100];
int L[100000];
char in1[20],in2[20],in[40];
const int pri = 99997;
bool used[100000];
int main()
{
read;
write;
int dx = 0;
memset(L,-1,sizeof(L));
while( gets(in)&&in[0]!=0 )
{
sscanf(in,"%s %s",in1,in2);
int hash = BKDRHash(in2)%pri;
strcpy(mem[dx].eng,in1);
strcpy(mem[dx].fri,in2);
mem[dx].next = L[hash];
L[hash] = dx++;
}
bool Isfind;
while(scanf("%s",in2)!=-1)
{
int hash = BKDRHash(in2)%pri;
dx = L[hash];
Isfind = false;
while(dx!=-1)
{
if( strcmp(mem[dx].fri,in2)==0 )
{
printf("%s\n",mem[dx].eng);
Isfind = true;
break;
}
dx = mem[dx].next;
}
if(!Isfind)
printf("eh\n");
}
return 0;
}