eolymp
bolt
Try our new interface for solving problems
Problems

Water Tank

Water Tank

Mr. Denjiro is a science teacher. Today he has just received a specially ordered water tank that will certainly be useful for his innovative experiments on water flow. \includegraphics{https://static.e-olymp.com/content/8b/8b324a355b9b983dba9edd6aa71ce10673c4163a.jpg} \textit{\textbf{Figure 1}}: The water tank The size of the tank is \textbf{100}cm (Width) * \textbf{50}cm (Height) * \textbf{30}cm (Depth) (see \textit{\textbf{Figure 1}}). For the experiments, he fits several partition boards inside of the tank parallel to the sideboards. The width of each board is equal to the depth of the tank, i.e. \textbf{30}cm. The height of each board is less than that of the tank, i.e. \textbf{50} cm, and differs one another. The boards are so thin that he can neglect the thickness in the experiments. \includegraphics{https://static.e-olymp.com/content/a7/a7143774eeff7d6ff6d66259725dee4f2997112b.jpg} \textit{\textbf{Figure 2}}: The front view of the tank The front view of the tank is shown in \textit{\textbf{Figure 2}}. There are several faucets above the tank and he turns them on at the beginning of his experiment. The tank is initially empty. Your mission is to write a computer program to simulate water flow in the tank. \InputFile The input consists of multiple data sets. \textbf{D} is the number of the data sets. \textbf{DDataSet_1DataSet_2...DataSet_D} The format of each data set (\textbf{DataSet_d} , \textbf{1} ≤ \textbf{d} ≤ \textbf{D}) is as follows. \textbf{NB_1 H_1B_2 H_2...B_N H_NMF_1 A_1F_2 A_2...F_M A_MLP_1 T_1P_2 T_2...P_L T_L} Each line in the data set contains one or two integers. \textbf{N} is the number of the boards he sets in the tank. \textbf{B_i} and \textbf{H_i} are the \textbf{x}-position (cm) and the height (cm) of the \textbf{i}^\{th \}board, where \textbf{1} ≤ \textbf{i} ≤ \textbf{N} . \textbf{H_i} differ from one another. You may assume the following. \textbf{0} < \textbf{N} < \textbf{10}, \textbf{0} < \textbf{B_1} < \textbf{B_2} < ... < \textbf{B_N} < \textbf{100}, \textbf{0} < \textbf{H_1} < \textbf{50}, \textbf{0} < \textbf{H_2} < \textbf{50}, ..., \textbf{0} < \textbf{H_N} < \textbf{50}. \textbf{M} is the number of the faucets above the tank. \textbf{F_j} and \textbf{A_j} are the \textbf{x}-position (cm) and the amount of water flow (cm^3/second) of the \textbf{j}^\{-th\} faucet , where \textbf{1} ≤ \textbf{j} ≤ \textbf{M}. There is no faucet just above any boards. Namely, none of \textbf{F_j} is equal to \textbf{B_i}. You may assume the following. \textbf{0} < \textbf{M} < \textbf{10}, \textbf{0} < \textbf{F_1} < \textbf{F_2} < ... < \textbf{F_M} < \textbf{100}, \textbf{0} < \textbf{A_1} < \textbf{100}, \textbf{0} < \textbf{A_2} < \textbf{100}, ... \textbf{0} < \textbf{A_M} < \textbf{100}. \textbf{L} is the number of observation time and location. \textbf{P_k} is the \textbf{x}-position (cm) of the \textbf{k}^\{-th\} observation point. \textbf{T_k} is the \textbf{k}^\{-th\} observation time in seconds from the beginning. None of \textbf{P_k} is equal to \textbf{B_i}. You may assume the following. \textbf{0} < \textbf{L} < \textbf{10}, \textbf{0} < \textbf{P_1} < \textbf{100}, \textbf{0} < \textbf{P_2} < \textbf{100}, ..., \textbf{0} < \textbf{P_L} < \textbf{100}, \textbf{0} < \textbf{T_1} < \textbf{1000000}, \textbf{0} < \textbf{T_2} < \textbf{1000000}, ..., \textbf{0} < \textbf{T_L} < \textbf{1000000}. \OutputFile For each data set, your program should output \textbf{L} lines each containing one real number which represents the height (cm) of the water level specified by the \textbf{x}-position \textbf{P_k} at the time \textbf{T_k}. Each answer may not have an error greater than \textbf{0.001}. As long as this condition is satisfied, you may output any number of digits after the decimal point. After the water tank is filled to the brim, the water level at any Pk is equal to the height of the tank, that is, \textbf{50} cm.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
5
15 40
35 20
50 45
70 30
80 10
3
20 3
60 2
65 2
6
40 4100
25 7500
10 18000
90 7000
25 15000
25 22000
5
15 40
35 20
50 45
70 30
80 10
2
60 4
75 1
3
60 6000
75 6000
85 6000
Output example #1
0.666667
21.4286
36.6667
11.1111
40
50.0
30
13.3333
13.3333
Source 2004 ACM International Collegiate Programming Contest, Japan Domestic Contest, Ehime, Japan, July 2, Problem E