Special Unit CH

Simulate a cart moving on a line with agents that board it, are shot, die, and revive, and report the cart's position at each query time.

Medium7SimulationImplementationNo attempts yetTime limit2sMemory limit64 MB

Problem

Special unit CH has to move a supply cart to its destination.

The mission happens on a number line. The cart and every agent sit at one point of that line, and coordinates are measured in meters. The cart starts at coordinate ss and has to reach coordinate ee.

In the picture the cart starts at 6 and has to reach 2, and four agents stand at 1, 7, -1 and 4.

If pp agents share the position of the cart at some moment, that is, they are riding it, the cart moves at pp m/s at that moment. The cart only moves toward the destination, and it stops as soon as it gets there.

Every living agent who is not riding the cart moves toward the cart at its own speed viv_i. An agent boards the cart the moment it reaches the point where the cart is, and once it boards it travels with the cart to the destination no matter what its own speed is.

An agent loses health when it is shot. An agent whose health drops to 0 or below dies. Ten seconds after it dies it comes back at its own starting position with full health and continues the mission. While it is dead it is not riding the cart and it adds nothing to the cart speed.

You are the archivist of CH and you hold every shooting record. Use those records to reconstruct the coordinate of the cart at each time you are asked about.

Input

The first line has the starting coordinate ss of the cart and the target coordinate ee, separated by a space. (0s10000 \le s \le 1\,000, 0e10000 \le e \le 1\,000)

The second line has the number of agents mm. (1m101 \le m \le 10)

Each of the next mm lines describes one agent. Line ii has the starting position xix_i in meters, the starting health hih_i and the speed viv_i in m/s of agent ii, separated by spaces. (0xi10000 \le x_i \le 1\,000, 150hi600150 \le h_i \le 600, 1vi10001 \le v_i \le 1\,000)

The next line has the number of shots ll. (1l1001 \le l \le 100)

Each of the next ll lines describes one shot. Line jj has the number aja_j of the agent that was hit, the time bjb_j of the shot in seconds and the health djd_j it removes, separated by spaces. (1ajm1 \le a_j \le m, 0bj10000 \le b_j \le 1\,000, 1dj6001 \le d_j \le 600)

The next line has the number of queries qq. (1q10001 \le q \le 1\,000)

Each of the next qq lines has one time tt in seconds at which you want the position of the cart. (0t10000 \le t \le 1\,000)

Every number in the input is an integer. A shot that hits an agent who is already dead at that time is ignored. If a revival and a shot happen at exactly the same time, the shot lands after the revival. At time 0 the cart and every agent are at their own starting positions.

Output

For each query time print the coordinate of the cart at that time, one per line. Print each coordinate rounded to six digits after the decimal point, rounding the seventh digit. No input puts a correct answer on a rounding boundary.