JOI Kingdom is a mysterious kingdom which has a boundless expanse of territory. JOI-kun, the king of JOI Kingdom, is planning to cut a part of the territory and make his garden.
The territory of JOI Kingdom is considered as a sufficiently large
Some artworks are placed on the territory. The artworks are classified into two types, Type A and Type B, according to the way to be placed in the territory.
- There are
kinds of artworks of type A. An artwork of -th kind ( ) is placed on every cell of the form , where , are integers. - There are
kinds of artworks of type B. An artwork of -th kind ( ) is placed on every cell of the form , where , are integers, or of the form , where , are integers.
Note that a cell may contain several artworks of different kinds.
JOI-kun is planning to choose a rectangular region on the grid to make a garden. In other words, he will
choose
Write a program which, given information of artworks, calculates the minimum number of cells in JOI-kun's garden.
Input Specification
Read the following lines from Standard Input.
Output Specification
Write one line to the standard output. The output should contain the minimum number of cells in JOI-kun's garden.
Constraints
. . . . ( ). ( ). ( ). ( ).- Given values are all integers.
Subtasks
- (15 points)
. - (6 points)
, . - (8 points)
, . - (16 points)
, . - (30 points)
. - (25 points) No additional constraints.
Sample Input 1
2 1 5
1 4
2 2
0 0
Sample Output 1
8
Explanation for Sample 1
The following figure describes the cells

In this figure, circles and diamond shapes are artworks of type A and B, respectively. An integer in a circle
or a diamond shape describes the kind of the artwork. If JOI-kun chooses
This sample input satisfies the constraints of all the subtasks.
Sample Input 2
3 4 100
20 26
81 56
20 3
58 71
74 82
95 61
95 61
Sample Output 2
2840
Explanation for Sample 2
This sample input satisfies the constraints of Subtasks 1, 4, 5, 6.
Sample Input 3
5 7 5000
1046 365
4122 1166
4009 2896
1815 4065
4372 1651
2382 123
1475 836
3313 4005
2579 568
4300 4867
1050 3214
3589 4653
Sample Output 3
10543092
Explanation for Sample 3
This sample input satisfies the constraints of Subtasks 1, 5, 6.
Comments