Lonely Mountain
"This was made by Thror, your grandfather, Thorin",
he said in answer to the dwarves’ excited questions.
"It is a plan of the Mountain."
J. R. R. Tolkien. The Hobbit, or There and Back Again
The plan of the Lonely Mountain consists of two parallel projections of the mountain to two projection planes. Both planes are perpendicular to the ground and each other. Each projection has a mountain-like shape.
Since Bilbo Baggins has never seen the mountain, he tries to imagine it. Is it really the Lonely Mountain or some ridges and other mountains surround it? In any case, it must be tremendous to hold the whole dwarves’ kingdom!
Bilbo decided to estimate the maximum possible volume of the Lonely Mountain and nearby mountains (if any) based on the plan provided by Gandalf.
Input
The first line contains single integer number n[x]
— the number of points in the parallel projection of the mountain to the plane Oxz (2 ≤ n[x]
≤ 100000). The second line contains n[x]
pairs of integer numbers x[i]
, z[i]
— the coordinates of the polygonal chain, representing the projection (-10^9
≤ x[1]
< x[2]
< x[3]
< ... < x[nx]
≤ 10^9
, 0 ≤ z[i]
≤ 10^9
, z[1]
= z[nx]
= 0).
The following two lines contain projection to the Oyz plane in the same format.
Output
The only line must contain a single number V — the maximum possible volume of the Lonely Mountain.
The absolute or relative precision of you answer should be at least 10-6. E.g. if V is the actual maximum possible volume, the following must hold: .
If there are no mountains corresponding to the given projections, output a single line "Invalid plan".