Deciphering Messages 

The plaintext messages are written in the standard 26-letter English alphabet, A-Z. The encryption is done with the help of a cipher key. This cipher key is composed of an ordered set L of English alphabet letters, which is called the alphabetical key, and an integer N in the interval [1..25], which is called the numerical key. Each word of k characters is encrypted into a word of length between k and k*3 characters. The encryption rules are as follows:

Rule 1:
Each word is encrypted separately; the space between words is preserved. Each word is encrypted from the leftmost to the rightmost letters.
Rule 2:
A plaintext message letter p that does not belong to L is enciphered as a ciphertext letter c = ciph(p) where ciph is a function defined below.
Rule 3:
A plaintext message letter p that belongs to L is enciphered as a string of three letters: the m-th letter of L, followed by a ciphertext letter c = ciph(p), followed by the (m + 1)-th letter of L. The value of m is incremented by one each time this rule is applied. Arithmetic is performed as if L were circular.

For each plaintext message the initial value for m is one.

The function ciph translates each letter to the letter N letters after it in the alphabet and arithmetic is performed as if the alphabet were circular (for example, if N is 2, then ciph(A) = C, ciph(B) = D,..., ciph(X) = Z;ciph(Y) = A;ciph(Z) = B).


NOTE: The keys used in the processes of ciphering and deciphering are such that the ciphered text can always be uniquely deciphered (that is, the keys do not contain images of function ciph for none of its elements).


Your task is to write a program to decode messages encripted by using the method just described.

Input 

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.


Input data file contains the alphabetical key in the first line, the numerical key in the second line, the number of messages that are to be deciphered in the third line, and a ciphered text message in each of the remaining lines. These text messages only contain uppercase letters in the standard 26-letter English alphabet and, if it is the case, also a space between words. These text messages supposedly result from the encryption of several original plaintext messages using the method described above with the cipher key given in the first and second lines of the input file.

Output 

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.


For each of the input ciphered text messages, output of the original plaintext message is required or an error message (`error in encryption') in case the input text is not a correct encryption of any plaintext message. The order of the messages must be preserved.

Sample Input 

1

RSAEIO
2
5
RTSSKAEAGE
GRSCAV
RGSSCAV
RUSIQO
RUSSGAACEV JEGIITOOGR

Sample Output 

RICE
error in encryption
EAT
error in encryption
SEAT HERE



Isabel Nunes, MIUP'2001