Special Judge Time Limit: 4000/2000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Tony is writing financial software. One of the components he is writing now will have to deals with risk and income graphs of various market instruments. Now he needs to plot the graph of a superposition of two continuous piecewise linear functions.

Tony is given two functions: f (x) and g(x) and needs to find the explicit representation of the function g(f (x)).

Tony is given two functions: f (x) and g(x) and needs to find the explicit representation of the function g(f (x)).

The input file consists of two blocks, one describes f and another describes g.

Each blocks starts with l — the number of intervals of linearity of a function (1 ≤ l ≤ 1000, l != 2).

If l > 2, the following l − 1 lines contain the breaking points of the function. Each line contains two integer numbers: x_{i}, y_{i }(i from 1 to l − 1, x_{i}< x_{i+1}). The function a(x) described by the block is defined as follows:

Here k_{i}= (y_{i+1} − y_{i})/(x_{i+1} − x_{i}).

If l = 1 the following line contains one integer number y, the function described is a(x) = y.

All coordinates in the input file do not exceed 10^{9 }by their absolute values.

Output the function g(f (x)) in the same format as the functions in the input file. The number of intervals of linearity in the description must be minimal possible. It is guaranteed that the number of intervals of linearity of the resulting function will not exceed 100 000. Output floating point numbers with absolute or relative precision of at least 10^{-}^{8}

.

.

3 0 0 2 3 4 0 0 1 3 2 0

4 0 0 0.666666666667 3 1.333333333333 0

Andrew Stankevich Contest 23