Destructor is a popular video game for a player can launch laser ray attack from a military satellite and destroy everything on a chosen point. Asuna is studying the strategy of the game. She managed to get some players' playing record but unfortunately she only has the inputs of the players and the scores are all lost. While Asuna's best friend, Kirito, is on a vacation in connect kingdom, she can only ask your help to simulate the game and recovery the players' scores. The game is round based and is played on a X Y grid. Only integer lattice points (x, y) where 0 ≤ x ≤ X, 0 ≤ y ≤ Y are used. The game starts at round 1 and following phases will occur in a round while one
phase is totally executed before the next one starts:
1. Every enemy existing on the board moves to its next position specified by its moving pattern. After the movement if one enemy is out of the allowed coordinate range, it is removed from the grid and player gained no points in this case. Note that multiple enemies could be at the same coordinate at the same time.
2. If there is an enemy planned to join the grid in this round according to the script, put it on its initial position on the grid unless the hard limit of 100 enemies on the whole grid has already been reached. In the case of hard limit exceeded this new enemy will be discarded and ignored in this game play while no points awarded to the player. There will be at most one enemy in the script trying to join the grid per round.
3. Player choose a coordinate to attack, remove every enemy on that coordinate. The summation of the scores of the removed enemies are added to the player's total score.
Enemy consists of an integer score, a moving pattern and its parameters, and a time denoting which round should this enemy join the grid. The initial position of an enemy is the rst position in its moving pattern. Each possible moving pattern is detailed explained in the following section:
guard Guard has only two parameters x, y (0 ≤ x ≤ X, 0 ≤ y ≤ Y ). It will be at (x; y) all the time.
jumper Jumper has four parameters x, y, dx, dy (0 ≤ x ≤ X, 0 ≤ y ≤ Y, -100 ≤ dx, dy ≤ 100). It will be at (x, y) initially and move the amount of vector (dx; dy) as delta each round after that. For example a jumper with parameters 1, 2, 3, -2 and join the grid at 3rd round
will be at (7, -2) at round 5.
bouncer Bouncer has four parameters x1, y1, x2, y2 (0 ≤ x1, x2 ≤ X; 0 ≤ y1, y2 ≤ Y ). Note that exactly one of x1 = x2 and y1 = y2 holds. Bouncer's initial position is (x1; y1) and will bounce between (x1; y1) and (x2; y2) at a speed of 1 grid unit per round. Note that turning is considered immediate so that bouncer will not stay at the end point for more than one round. For example a bouncer with parameters 1, 2, 1, 4 and join the grid at 3rd round will be back at its initial position at round 7, round 11 ... and so on.
teleporter Teleporter has two parameters x, y (0 ≤ x ≤ X, 0 ≤ y ≤ Y ). It's initial position is (x, y). In each round it will teleport to the position being attacked last round starting from the next round joined the grid.
avoider Avoider has two parameters x, y (0 ≤ x ≤ X, 0 ≤ y ≤ Y ). It will avoid the position being attacked last round. Assume the coordinate of the last attack is (xatk; yatk) and current position of avoider is (xa; ya).
The avoider will move 1 unit along +x axis if xa > xatk, 1 unit along -x if xa < xatk and no movement along x axis if xa = xatk. Same applies to y axis. So if an avoider is at (2, 4) at the end of last round and player choose to attack (3, 4) last round, avoider will move to (1, 4) this round.
Note jumper and avoider have the chance to go out of grid when moving and being eliminated. Asuna will give you the script along with the coordinates chosen by the player every round. Please report the total score to Asuna.
The first line of the input data contains an integer T (1 ≤ T ≤ 100) specifying the number of test cases.
The first line of each test case contains two integers X and Y (0 ≤ X, Y ≤ 107) indicating the grid size.
The second line contains a single integer EN (0 ≤ EN ≤ 1000) indicating the number of enemies. The following EN lines each describes an enemy, an integer time (1 ≤ time ≤ 1000) indicating the joining round, an integer score (1 ≤ score ≤ 107) indicating the score and a string pattern (one of "guard", "jumper", "bouncer", "teleporter", "avoider") for the pattern type followed by the parameters of that type. These lines are sorted increasingly by time.
The following line of each test case contains an integer playtime (1 playtime 1000) indicating the number of the rounds fully played.
The next playtime lines each contains two integers x and y (1 ≤ x ≤ X; 1 ≤ y ≤ Y ). The ith line of them indicating the player's choice for
destruction coordinate at round i.
Please note some constraints are stated in the problem description part.
For each test case, output a line starts with "Total Score: " and the final total score. Note " " is for clarity.