String Transformations ---------------------- Do those students that take 1030 still remember how to manipulate strings? Given several string transformation rules, transform a target string. Each string transformation rule (production) transforms a single letter into two letters, and is applied to the first occurrence of the letter in the target string. If the letter does not appear then the string is unchanged. Once a new string is produced, it is used as the target string of the next transformation rule, until no rules are left. For instance, the production A -> OA applied to the string "CAT" yields the string "COAT". Applied to the string "DATA" it yields the string "DOATA". Input ----- The first line contains the number of test cases (< 100). After that, each test case consists of two lines. The first line contains a number of transformation rules of the form lhs -> rhs where lhs is a single letter, and rhs is two letters. The transformation rules are separated by a single space. The second line contains the list of words to be transformed. You may assume all words are in capital letters. Output ------ For each test case, you are to output the transformed words in their original order, separated by a single space on a single line. Sample input ------------ 3 A -> OO A BAT ART DATA A -> AR A -> AO A -> TH A VS HULK X -> HX X -> UX X -> LK X JOINS AVENGERS Sample output ------------- OO BOOT OORT DOOTA THOR VS HULK HULK JOINS AVENGERS