QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#11659. Polygons

统计

Yesterday Little John had a test on geometry. The description of the most difficult problem follows. Given two triangles $ A $ and $ B $, calculate the area of region $ A + B $, which is defined as follows: $ A + B = \{p_{1} + p_{2} : p_{1} \in A, p_{2} \in B\}$. For example, if $ A $ has the vertices (0, 0), (0, 2), (2, 0) and $ B $ has the vertices (0, 0), (0, 1), (3, 0), then $ A $ + $ B $ is a polygon with the vertices (0, 0), (0, 3), (3, 2) and (5, 0), so its area is 9.5.

Afterwards, John started to wonder how to solve a modified problem - "How to calculate area of $ A + B $, if $ A $ and $ B $ are arbitrary convex polygons". Little John has a test on biology tomorrow and has no time to solve this problem himself. He asked you for help in solving this task.

Write a program, which:

  • reads the descriptions of two convex polygons $ A $ and $ B $,
  • computes the area of $ A + B $,
  • writes it doubled to the standard output.

Input Format

The first line of the standard input contains two integers $ n $ and $ m $ ($3 ≤ n, m ≤ 100\,000$) separated with a single space and denoting the numbers of vertices of polygons $ A $ and $ B $. In the second line there are $ n $ pairs of integers ($ x_{i} $, $ y_{i} $) ($-100\,000\,000 ≤ x_{i}, y_{i} ≤ 100\,000\,000$), denoting the coordinates of consecutive vertices of the polygon $ A $ (in the clockwise order). In the third line there are $ m $ pairs of integers $(x_i, y_i)$ ($-100\,000\,000 ≤ x_{i}, y_{i} ≤ 100\,000\,000$) denoting the coordinates of consecutive vertices of the polygon $ B $ (in the clockwise order).

Output Format

The first and only line should contain one integer - doubled area of $ A + B $.

Example

Input

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

Output

18