// Arup Guha
// 2/1/2025
// Solution to Babelfish
// https://open.kattis.com/problems/babelfish

import java.util.*;

public class babelfish {

	public static void main(String[] args) {

		// Get first line set up map.
		Scanner stdin = new Scanner(System.in);
		String line = stdin.nextLine();
		HashMap<String,String> mymap = new HashMap<String,String>();
		
		// Go until blank line.
		while (line.length() != 0) {
		
			// Split words, map foreign to English.
			StringTokenizer toks = new StringTokenizer(line);
			String eng = toks.nextToken();
			String foreign = toks.nextToken();
			mymap.put(foreign, eng);
			
			// Get next line.
			line = stdin.nextLine();
		}
		
		// Process queries.
		while (stdin.hasNext()) {
		
			// Read it and translate with map.
			line = stdin.nextLine();
			if (mymap.containsKey(line))
				System.out.println(mymap.get(line));
			else
				System.out.println("eh");
		}
	}
}