Six messengers relay a message one after another. Each messenger always applies the same fixed change to the message before passing it on, so the message that finally reaches the King differs from the original.
A message is a non-empty string of digits (0-9) and letters (a-z, A-Z); uppercase and lowercase are distinct. The six messengers and their transformations are:
aB23d becomes B23da.aB23d becomes daB23.e3ac becomes ace3, and aB23d becomes 3d2aB.aB23d becomes d32Ba.9 becomes 0. Letters are unchanged. For example, aB23d becomes aB34d, and e9ac becomes e0ac.0 becomes 9. Letters are unchanged. For example, aB23d becomes aB12d, and e0ac becomes e9ac.Given the order in which the messengers relayed the message and the message the King finally received, recover the original message.
For example, suppose the order is A, J, M, P and the King received aB23d. Applying the transformations to the original message in that order gives:
32BaddaB23aB23daB12daB23d (the message the King received)So the original message is 32Bad.
The first line contains a positive integer $n$, the number of data sets. Each data set is given on two lines:
J, C, E, A, P, M);The number of messengers in an order is between $1$ and $6$ inclusive, and no messenger appears more than once in a single order. The length of each message is between $1$ and $25$ inclusive.
For each data set, print the recovered original message on its own line.