And Now, a Remainder from Our Sponsor

Time limit1sMemory limit128 MB

Problem

IBM has decided that all messages sent to and from teams competing in the ACM programming contest should be encoded. Instead of sending the letters of a message directly, they transmit their remainders relative to some secret keys, which are four two-digit integers that are pairwise relatively prime.

The letters of a message are first converted into numeric equivalents, where $A = 01$, $B = 02$, $\ldots$, $Z = 26$, and a blank $= 27$. Each group of 3 letters is then combined to create a 6-digit number. (If the last group does not contain 3 letters, it is padded on the right with blanks and then transformed into a 6-digit number.) For example:

THE CAT IN THE HAT -> 200805 270301 202709 142720 080527 080120

Each six-digit integer is then encoded by replacing it with its remainders modulo the four secret keys. Each remainder is padded with leading zeros, if necessary, to make it two digits long. The four remainders are concatenated together, and then any leading zeros are removed. For example, if the secret keys are $34$, $81$, $65$, and $43$, then the first integer $200805$ has remainders $1$, $6$, $20$, and $38$; by the rules above these combine to the encoding $1062038$. The entire sample message above is encoded as:

1062038 1043103 1473907 22794503 15135731 16114011

Given the secret keys and an encoded message, recover and print the original message.

Input

The input consists of multiple test cases. The first line contains a single positive integer $n$, the number of test cases. The next $2n$ lines contain the test cases.

The first line of each test case contains a positive integer (less than $50$) giving the number of encoded groups in the message. The second line contains the four keys followed by the encoded message; each of the four keys and each message group is separated by a single space.

It is guaranteed that the product of the four keys is greater than $272727$ (the largest possible six-digit group value), so every encoded message decodes to exactly one original message.

Output

For each test case, print the decoded message on its own line. Do not print any trailing blanks.