First, there is a car whose coordinate is (0, 0) and it’s facing the positive direction of Y-axis. Then it is given a sequence of instructions which it should act one by one. The instructions are classified into three and only three types:
Type A: Go forward x meters and turn right, then go forward y meters and turn right.
Type B: Go forward x meters and turn left, then go forward y meters and turn left.
Type C: Go forward x meters and turn right, then go forward y meters and turn right, next go forward z meters and turn right, finally go forward w meters and turn right.
And it is guaranteed:
1. While acting the instructions, the car’s x-coordinate will be always inside [0, 230) and its y-coordinate will be always inside (-230, 230).
2. Two adjacent instructions won't be of the same type.
3. The instruction of type C will be given only one time in the sequence.
4. The car will be back to the starting point when it finishes acting all instructions in the sequence.
5. The car’s path has no intersection.
Please calculate the area of the polygon surrounded by the path the car passes by acting all instructions in the order.
The first line contains the integer N,the numbers of instructions in the sequence.
Next N lines describe the instructions in the sequence.For each line, you are given an upper-case letter which means the type of instruction. “A” means type A, “B” means type B and “C” means type C.
If you are given an instruction of type A or B, next you will be given two integers x and y. If you are given an instruction of type C, you will be given four integers x, y, z and w
.
Only one integer means the area of the polygon surrounded by the path the car passes by acting all instructions in order.