#pragma warning(disable:4996)
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int INF = 0x3f3f3f3f;
struct node
{
char str1[15];
char str2[15];
}letter[100005];
bool cmp(node a, node b)
{
return strcmp(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;
}
else if (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");
else
printf("%s\n", letter[index].str1);
}
return 0;
}
#pragma warning(disable:4996)
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
char str1[15], str2[15],str[30];
map<string,string> Map;
while (gets(str))
{
if (strlen(str) == 0)
break;
sscanf(str, "%s %s", str1, str2);
Map[str2] = str1;
}
string str3, temp;
while (cin >> str3)
{
temp = Map[string(str3)];
if (temp.length()== 0)
cout << "eh" << endl;
else
cout << temp << endl;
}
return 0;
}