cho.sh
Notes
Loading...

Convex Polygon Intersection Area

Time limit

2s

Memory limit

128 MB

Problem

Two convex polygons are given. Both polygons have nonzero area, and no vertex of either polygon lies on an edge of the other polygon.

Write a program that computes the area of the region where the two polygons overlap.

Input

The first line contains N, the number of vertices of the first convex polygon, and M, the number of vertices of the second convex polygon. N and M are positive integers not greater than 100.

The next N lines contain the vertices of the first convex polygon in counterclockwise order. The following M lines contain the vertices of the second convex polygon in counterclockwise order.

Every coordinate is an integer whose absolute value is at most 1,000. Each convex polygon has nonzero area.

Output

Print the area of the region where the two polygons overlap. An absolute or relative error of at most 10^-9 is accepted.