A clan of ninjas found a peculiar map divided into squares approximately 0.5 \times 0.5 inches in size. In the middle, at a spot known as a pirate foothold, there is a square marked . The adjacent squares from the north to the west are labeled , , , and , respectively. This unusual numbering puzzled the ninjas for a long time, until the cleverest among them realized it was related to dice: if the top shows , and you roll (tilt) the die to the neighboring square on the right, will appear on top (depending, of course, on the orientation of the die). Alongside the map, they found a strange text initially attributed to the Bay Area Poets Coalition, though it seemed unlikely that even Joyce could have devised such a cryptic poem.
The first sentence reads "5X-YYX+Y.". They discovered its meaning:
means one square to the east.
means one square to the north.
abbreviates , and means XXXYX.
A minus sign indicates the directions are reversed (east becomes west, north becomes south), while a plus sign restores the original directions. The sequence ends with a dot . The number of dots appearing on the top face of the die in its final position signifies what can be found at that spot: a hut, a weapons cache, a well, or even a place of unspeakable horror.
Your task is to compute the coordinates of the final position (relative to the starting point) and determine the number of dots on the top face.
The first line contains the number of test cases. Each test case consists of:
One line containing a sequence.
A sequence may contain digits, , , , , and ends with a dot. The sequence contains at most characters. Numbers in the sequence consist of at most digits and are never zero.
For each test case, output a line: position (x; y), z dots where is the final position of the die and is the number of dots showing on the top face in the final position.
Beispiel 1