Welcome to ZOJ
 Contests Information Problems Runs Statistics Ranklist Clarification
125 - The 13th Zhejiang University Programming Contest - F
Fawful's Revenge

Time Limit: 2 Seconds      Memory Limit: 32768 KB

"I have fury!" Fawful shouted, with his circular platform floating upon the lava. Standing in the spotlight, Fawful reared his ugly head. The platform gradually closed its shell and became semi-sphere. It was Fawful's most powerful weapon to defeat the Mario Bros. It could protect Fawful from any damage from the Mario Bros and could send out beams and thunder ball to attack them. Its most attack was the spiral thunder ball attack. It would generate several rotating thunder balls to attack them. Each time they were hit by a thunder ball, their HP would decrease. For the attack lasted for a long time, the damage might make their HP fall down to 0.

However, this weapon had a fatal disadvantage. After the powerful attack, the weapon would become overheated and Fawful had to go out. This was the best chance to attack Fawful directly. So the most important thing was to survive from the powerful attack. Given the controlling instructions and the details of the attack, you are asked to calculate the damage each of the Bros get.

Specifically, Mario and Luigi were standing at the distance of D. Mario was at the angle of A degrees to the front of Fawful while Luigi was b degree counterclockwise. The instruction 'L' is to control Mario's action and 'R' is to control Luigi's action. All the instructions are processed immediately. But there is an action time T within which to the last instruction the instructions to the same character are ignored. The attack could be devided into two stages.

In the first stage, it created N thunder balls at time 0. The thunder balls were distributed on the circle of radius R and the first one was in the front of Fawful. The radius of each thunder ball was r. They were rotating at w rad/s counterclockwise. During this stage, the Bros used their hammers destroy the thunder balls as they received instructions. A thunder ball was destroyed if at least one of its point was between the character and Fawful at the time of the instruction.

After T1 seceonds of charging, the attack went into the second stage. The orbit of the thunder balls went from the circle of radius of R to the circle of radius D at that time with the same angular speed. During this stage, the Bros could only jump up to avoid thunder balls. After the instruction received, the corresponding character would jump up for T seconds and he would not be hurt in this period. Each time hit by a thunder ball, no matter when landing after the jump or staying on the ground, Mario's HP would decrease M points while Luigi's would decrease L points. The attack would end at time T2, when all the thunder balls disappear.

Input

The first line of the input contains an integer C, the number of rounds Fawful attacked. For each round, the first line contains 13 numbers, a, b, T, N, D, R, r, w, T1, T2, M and L, which are mentioned above. It is guaranteed that -180 < a, b ≤ 180, T > 0, 0 ≤ N ≤ 50000, 0 < r < R, r + RD ≤ 100000, 0 ≤ T1T2 ≤ 1000000000 and M and L are two positive integers not exceeding 1000. It is also guaranteed that the thunder balls do not touch or overlap each other and no thunder ball will touch the Bros at T1. The next line contains an integer n(0 ≤ n ≤ 30000, the number of instructions. Then n lines follow, each of which is in the form of "Time Instruction"(without quotes). The time will be nonnegative and less than T2 and the instructions contain 'L' and 'R' only. The instructions are listed in strictly increasing order by the time.

Output

For each round, output the total damage of the Bros in one line.

Sample Input

```1
15 -15 1.1 4 6 4 2 3.14 2 4 2 3
4
0.08 L
0.42 R
1.08 L
2.81 R
```

Sample Output

```4
```

Hint

The first instruction makes Mario destroys the first thunder ball. The second instruction makes Luigi destroys another thunder ball. The third instruction is ignored. The fourth instruction makes Luigi jumps and avoids the two thunder balls. Hence, Mario is hit by the two thunder balls once totally and the total damage is 4.

Submit    Status