P6214 "SWTR-4" Taking a Walk

Background

Little A likes taking a walk in the square. Once, while Little A was walking, he was thinking too deeply and accidentally ran into a utility pole. So this problem came out (of course, it is fake).

Description

Little A and his friend Little Y are standing on a plane. Their initial coordinates are $(Ax_0,Ay_0)$ and $(Bx_0,By_0)$, respectively. Of course, standing still is too boring, so they will keep moving. More precisely, Little A makes a total of $n$ moves, and Little Y makes a total of $m$ moves. From time $At_{i-1}$ to time $At_i$, Little A moves from $(Ax_{i-1},Ay_{i-1})$ to $(Ax_i,Ay_i)$ with **uniform linear motion**. From time $Bt_{i-1}$ to time $Bt_i$, Little Y moves from $(Bx_{i-1},By_{i-1})$ to $(Bx_i,By_i)$ with **uniform linear motion**. - $At_0=Bt_0=0$. Little A also has $q$ queries. Each query gives a floating-point number $c$ and an integer $f$, asking you to find the time when their distance is $c$ for the $f$-th time. - **Special case: if there are infinitely many times when their distance is $c$**, output `-2.33`. - **Special case: if $f$ is greater than the number of times their distance is $c$**, output `-4.66`. - Otherwise, output the time when their distance is $c$ for the $f$-th time.

Input Format

The first line contains three integers $n,m,q$, where $n$ is the number of moves of Little A, $m$ is the number of moves of Little Y, and $q$ is the number of queries. The second line contains four floating-point numbers with two decimal places $Ax_0,Ay_0,Bx_0,By_0$, representing the initial coordinates of Little A and Little Y. The next $n$ lines: the $i$-th line contains three floating-point numbers with two decimal places $Ax_i,Ay_i,At_i$, as described above. The next $m$ lines: the $i$-th line contains three floating-point numbers with two decimal places $Bx_i,By_i,Bt_i$, same as above. The next $q$ lines: each line contains a floating-point number with two decimal places $c$ and an integer $f$, describing a query.

Output Format

Output $q$ floating-point numbers in total, representing the answer to each query.

Explanation/Hint

**Special Judge** **This problem uses Special Judge.** If the **relative error or absolute error** between your output and the correct answer is at most $10^{-7}$, you will get full score for that test point. Otherwise, you will get no score. **It is recommended to output at least $8$ digits after the decimal point**. Please do not output any numbers other than what the problem asks for, otherwise you may get UKE. It is guaranteed that there is no case where the answer is $0$. The SPJ is as follows: ``` #include "testlib.h" #define double long double const double eps=1e-7; bool Equal(double x,double y){ return abs(x-y)