#pragma warning(disable:4996)#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<vector>#include<algorithm>#include<iostream>#include<time.h>usingnamespacestd;
constint INF = 0x3f3f3f3f;
struct node
{
char str1[15];
char str2[15];
}letter[100005];
bool cmp(node a, node b)
{
returnstrcmp(a.str2,b.str2)<=0;
}
int BinarySearch(node a[], int size, char* str)
{
int left = 1;
int right = size;
int m = left + (right - left) / 2;
while (left <= right)
{
if (strcmp(a[m].str2, str) == 0)
{
return m;
}
elseif (strcmp(a[m].str2, str) < 0)
{
left = m + 1;
m = left + (right - left) / 2;
}
else
{
right = m - 1;
m = left + (right - left) / 2;
}
}
return -1;
}
int main()
{
char str[30];
int k;
k = 1;
while (gets(str))
{
if (str[0] == '\0')
break;
sscanf(str,"%s%s", letter[k].str1, letter[k].str2);
k++;
}
sort(letter + 1, letter + k,cmp);
while (gets(str))
{
int index = BinarySearch(letter, k - 1, str);
if (index == -1)
printf("eh\n");
elseprintf("%s\n", letter[index].str1);
}
return0;
}