Description

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

Input

Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
atcay
ittenkay
oopslay

Sample Output

cat
eh
loops
#include<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#define size 100001
typedef 
struct
{
    
char p1[11];
    
char p2[11];
}
T;
T str[size];
int q_cmp(const void *a, const void *b)//快速排序函数原型 
{
    
return strcmp(((T*)a)->p2, ((T*)b)->p2);
}

int b_cmp(const void *a, const void* b)//二分查找函数原型 
{
    
return strcmp((char*)a, ((T*)b)->p2);
}


int main()
{
    
char s[30];
    
int i = 0;
    T 
*ptr;
    
while (1)
    
{
        gets(s);
        
if (s[0== '\0')
        
{
            
break;
        }

        sscanf(s, 
"%s %s", str[i].p1, str[i].p2);//s中相当于两段被空格隔开的字串,从数组s中读取内容到p1 和 p2 中 
        i++;    
    }

    qsort(str, i, 
sizeof(T), q_cmp);//对str进行快排 
    while (gets(s))
    
{
        ptr 
= (T*)bsearch(s, str, i, sizeof(T), b_cmp);//从str中查找 ,根据b_cmp的定义规则,这里是在str[i].p2中查找(i = 0,1,……n),返回的是NULL或str[i] 
        if (ptr)
        
{
            puts(ptr
->p1);
        }

        
else
        
{
            puts(
"eh");
        }

    }
            
    
//system("pause");
    return 0;
}