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 MBSpecial 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 s and has to reach coordinate e.

In the picture the cart starts at 6 and has to reach 2, and four agents stand at 1, 7, -1 and 4.
If p agents share the position of the cart at some moment, that is, they are riding it, the cart moves at p 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 vi. 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.
The first line has the starting coordinate s of the cart and the target coordinate e, separated by a space. (0≤s≤1000, 0≤e≤1000)
The second line has the number of agents m. (1≤m≤10)
Each of the next m lines describes one agent. Line i has the starting position xi in meters, the starting health hi and the speed vi in m/s of agent i, separated by spaces. (0≤xi≤1000, 150≤hi≤600, 1≤vi≤1000)
The next line has the number of shots l. (1≤l≤100)
Each of the next l lines describes one shot. Line j has the number aj of the agent that was hit, the time bj of the shot in seconds and the health dj it removes, separated by spaces. (1≤aj≤m, 0≤bj≤1000, 1≤dj≤600)
The next line has the number of queries q. (1≤q≤1000)
Each of the next q lines has one time t in seconds at which you want the position of the cart. (0≤t≤1000)
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.
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.