# Arup Guha
# 2/1/2025
# Babelfish
# https://open.kattis.com/problems/babelfish

toks = input().split()
mydictionary = {}

# Go through dictionary
while len(toks) == 2:

    # Add mapping.
    mydictionary[toks[1]] = toks[0]

    # Get next entry.
    toks = input().split()

# process queries.
query = input()

# We stop when there's no line.
while query != "":

    # We can translate it.
    if query in mydictionary:
        print(mydictionary[query])

    # We can not.
    else:
        print("eh")

    # Get next item.
    try: 
        query = input()
    except EOFError:
        break
        
