The world's first full-scale, stored-program, electronic, digital computer was the EDSAC (Electronic Delay Storage Automatic Calculator). The EDSAC had an accumulator-based instruction set, operating on -bit words (and -bit double words), and used a -bit teletypewriter code for input and output.
The EDSAC was programmed using a very simple assembly language: a single letter opcode followed by an unsigned decimal address, followed by the letter "F" (for full word) or "D" (for double word). For example, the instruction "A 128 F" would mean "add the full word at location 128 to the accumulator", and would be assembled into the -bit binary value , consisting of a -bit opcode (="add"), an -bit operand (00010000000 = 128), and a single bit denoting a full word operation (a bit would indicate a double word operation).
Although arithmetic on the EDSAC was fixed point two's complement binary, it was not mere integer arithmetic (as is common with modern machines). The EDSAC hardware assumed a binary point between the leftmost bit and its immediate successor. Thus the hardware could handle only values in the range -1.0 \leq x < 1.0. For example:
As you can see, the largest possible positive value was:
01111111111111111 = 0.9999847412109375
and the smallest possible positive value was:
00000000000000001 = 2^{-16} = 0.0000152587890625
(This also happens to be the increment between successive values on the EDSAC).
By a curious coincidence (or an elegant design decision), the opcode for the add operation () was the same as the teleprinter code for the letter "A". The opcode for subtract was the same as the teleprinter code for "S" (), and so on. This simplified the programming for the assembler (which, incidentally, was a mere instructions long). The EDSAC teleprinter alphabet was "PQWERTYUIOJ#SZK*?F@D!HNM&LXGABCV" (with "P"=, "Q"=, and so on, up to "V"=).
Unfortunately, the EDSAC assembler had no special directives for data values. On the other hand, there was no reason that ordinary instructions couldn't be used for this, thus, an EDSAC programmer desiring to reserve space for the constant (represented as ) would use the instruction "S O F" and for (which is approximately represented as ) "T 682 D", and so on.
Your job is to write a program that will translate EDSAC instructions into the appropriate decimal fractions.
The first line of input contains a single integer (1 \leq P \leq 1000) which is the number of data sets that follow. Each data set is a single line that contains (the dataset number), followed by a space, followed by an EDSAC instruction of the form: , where is a single character in the EDSAC alphabet, is an unsigned decimal number (0 \leq d < 2^{11}), and is either a 'D' or 'F'.
For each data set there is one line of output. It contains the data set number () followed by a single space, followed by the exact decimal fraction represented by the by the EDSAC instruction, including a minus sign (for negative values). The format for the decimal fraction is: , where is an optional minus sign, is either a or , and is any decimal digit (-). There must be at least and at most digits after the decimal point. Trailing zeros in the fraction must be suppressed.
Example 1