A clan of ninjas has come across a strange map: it is divided into squares roughly 0.5 by 0.5 inch in size. Somewhere in the middle, on a spot known to be a stronghold of pirates, the square is marked with 1, while its four neighbouring squares, going clockwise starting from the north (north, east, south, west), bear the numbers 2, 3, 5, and 4 respectively.
This strange numbering puzzled the ninjas for a long time, until the brightest gambler among them discovered that it had something to do with dice: if the top shows 1 and you roll -- or rather tilt -- the die to the right onto the neighbouring square, then 3 appears on top (this depends, of course, on the orientation of the die). In other words, the number written on a square equals the top face of the die after it is rolled from the central square (top 1) onto that square. Given the four neighbour values and the starting top value 1, the arrangement of all six faces of the die is uniquely determined.
Together with the map, they got their hands on a strange text. Its first sentence reads 5X-YYX+Y., and they figured out what it means:
X means one square to the east.Y means one square to the north.3X is an abbreviation for XXX, and 3XYX means XXXYX.- reverses the directions (east becomes west and north becomes south); the plus sign + restores the original directions. The sequence starts in the original (+) mode...The number of dots on the top of the die in its final position signifies what is to be found on this spot: a hut, a hiding place for weapons, 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 to determine how many dots are shown on top of the die. East is the direction of increasing x, and north is the direction of increasing y.
The first line of the input contains a single integer: the number of test cases that follow. Each test case has the following format:
A sequence may contain digits and the characters +, -, X, Y, and ends with a dot. A sequence contains at most 1000 characters. The numbers in the sequence consist of at most 7 digits and are never zero.
For every test case, output a single line of the form position (x,y), z dots, where (x, y) is the final position of the die and z is the number of dots shown on top of the die in that position. Do not put a space after the comma between the coordinates (for example, (4,-1)).