Cracking the Code

No attempts yetTime limit2sMemory limit128 MB

Problem

The terror group NWERC (New World Ensemble for Rebellious Coders) is threatening our society. We found a way to intercept their traffic without being noticed. The trouble is that every message is encrypted.

Our informants learned two things. The messages consist of lowercase letters only, and the cipher is BAPC (Basic Alphabet Permutation Code), a one-to-one substitution. Every occurrence of a letter becomes the same single character, and that character may be the original letter. Two letters that differed before encryption always differ after encryption. For example, "hello" can be encrypted as "ifmmp" or "holle", but never as "cnoiz" or "bgrrb".

That fact alone leaves far too many possibilities, so every attempt at decryption failed. Then an informant obtained one plaintext sentence. That sentence very likely corresponds to exactly one of the ciphertexts we have collected since the beginning.

You are given one plaintext sentence and a list of ciphertexts. Recover as much of the substitution table for the 26 letters a to z as this material allows, then decrypt the recently intercepted message XX as far as you can and print the result.

If a letter of XX has exactly one possible decryption, print that letter. If it can be decrypted to two or more different letters without contradiction, print '?' in that position.

When two or more ciphertexts in the list correspond to the plaintext, you cannot tell which one should build the substitution table. Even then some letters may still be pinned to a single value, so be careful.

Input

The first line contains the number of test cases TT. (T100T \le 100)

Each test case has the following form.

  • an integer NN (1N1001 \le N \le 100): the number of ciphertexts
  • the next NN lines: the ciphertexts
  • the next line: the plaintext
  • the next line: the message XX to decrypt

Every string has length between 1 and 1000 and consists of lowercase letters only.

Output

For each test case, print the decryption of XX on one line.

Print the decrypted letter where it is determined uniquely and '?' where it is not. If no ciphertext in the list corresponds to the plaintext, print "IMPOSSIBLE" instead of a decryption.