Under construction

Still being built. Things may change

Banana

Interview

Time limit2sMemory limit512 MB

Summary
Read a dictionary mapping English words to Minionese words, then translate each of T sentences word by word.
Level

Easy2 of 10

Topics
Hash map, String, Implementation, Brute force
Solved
No attempts yet

Problem

After NASA discovered water on Mars, they decided to expand their exploration hoping to find some alien intelligence on the planet. After months of exploration, they were actually surprised to find out that the planet has been inhabited by minions.

NASA started communications with the minions and the first message they received was Mo amo Banana. At first, it was really hard to decipher the message but after sometime they managed to workout a dictionary that maps English words to Minionese words. You are going to help NASA build the translator to ease their communication with Minions for the good and prosperity of mankind and minionkind.

Input

The first line of input will contain a single integer N, the number of words in the dictionary (1 ≤ N ≤ 100). The following N lines will each contain a sentence of the format x = y where x is an English word and y is a Minionese word. The next line will contain an integer T, the number of test cases (1 ≤ T ≤ 100). Each test case will start with a line containing an integer K, the number of words in the sentence (1 ≤ K ≤ 100) and the next line will contain K space separated English words. All the English words in the test cases exist in the defined dictionary. Also, all the words consist only of English alphabet, and will be at most 20 characters long.

Output

For each test case, print a single line containing the space separated Minionese words after translation.

Examples1

  1. Example 1

    Input
    4
    I = mo
    love = amo
    icecream = gelatooo
    banana = banana
    2
    3
    I love banana
    3
    I love icecream
    
    Expected output
    mo amo banana
    mo amo gelatooo