cho.sh
Notes
Loading...

Maximum Volume from Orthogonal Projections

Time limit

2s

Memory limit

128 MB

Problem

There is a convex solid in three-dimensional space. When this solid is projected orthogonally onto the xz-plane and the yz-plane, each projection is a convex polygon.

Given the shapes of these two projections, compute the maximum possible volume of an original convex solid that matches them. The two projections do not determine the solid uniquely, so you must output the largest volume among all possible convex solids.

Input

The first line contains Nxz, the number of vertices of the projection on the xz-plane. (3 <= Nxz <= 1,000)

Each of the next Nxz lines contains two integers x and z, the coordinates of a vertex of Pxz, in clockwise order.

The next line contains Nyz, the number of vertices of the projection on the yz-plane. (3 <= Nyz <= 1,000)

Each of the next Nyz lines contains two integers y and z, the coordinates of a vertex of Pyz, in clockwise order.

The absolute value of every coordinate is at most 500. Both input polygons are convex. The minimum z-coordinates of the two polygons are equal, and their maximum z-coordinates are also equal. Adjacent vertices in each polygon are always distinct, but three or more input vertices may lie on the same side.

Output

Print the maximum possible volume of the original solid.

An absolute or relative error of at most 10^-2 is accepted.