#
The Turtle’s Journey

The Logo programming language is very well known by programmers all around the world. Today we’re presenting a new programming language inspired by Logo, called MicroLogo. It is a subset of the original language, and has only 4 instructions plus 2 special keywords. The keywords are begin and end, which denote the beginning and end of a complete program. The instructions are:
• left X: The turtle turns left X degrees.
• right X: The turtle turns right X degrees.
• forward X: The turtle moves forward X steps.
• repeat N [ INST ]: The turtle executes the instructions in INST, exactly N times.
In order to give you a precise definition of the language, here is its grammar, in BNF notation:
::= "begin" "end"
::=
| ""
::= |
| |
::= "left"
::= "right"
::= "forward"
::= "repeat" "[" "]"
::= [1-9][0-9]*
Whitespace separates tokens, and can be any sequence of one or more characters from the list: space (ASCII value 32), tab (ASCII value 9) or line feed (ASCII value 10).
Given a MicroLogo program, your task is to determine 3 values from it: the total amount of degrees the turtle covers turning left, the total number of degrees it covers turning right, and the total number of steps the turtle moves forward.
Input
The input starts with a number N in a single line, which is the number of MicroLogo programs present in the input. This is followed by the code for the N programs. It can be safely assumed that all programs are valid and the total size of a single program never exceeds 1000 characters. In addition, all numbers in every program will be positive integers no larger than 104.
Keep in mind that all programs can contain any number of arbitrary whitespace between its tokens, as described above.
N ≤ 100 Output
For every test case, print a line with three integers. In order: the total amount of degrees the turtle turns left, the total of degrees the turtle turns right, and the number of steps the turtle moves forward.
Since these results can become very large, print these numbers modulo 1000003 (106 + 3).

2/2 Sample Input
2
begin
forward 10
left 90
forward 10
left 90
forward 10
left 90
forward 10
left 90
end
begin
forward 10
left 90
forward 10
left 90
forward 10
left 90
forward 10
left 90
end
Sample Output
360 0 40
360 0 40