시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB52201664.000%

문제

The fanciest hall of Prince Ville’s new castle has a rectangular floor. The walls of the hall run from North to South and from East to West. Ville’s advisors have proposed to cover some parts of the floor with carpets and even suggested a specific arrangement of them.

Ville, caring mostly only about the quantitative aspect of the deal, would like to know the total area covered by the carpets in the proposed arrangement.

입력

The first line of input contains three space-separated integers: the number of carpets $K$ ($1 ≤ K ≤ 3$), the distance $L$ from the East wall to the West wall ($1 ≤ L ≤ 10^6$), and the distance $P$ from the North wall to the South wall ($1 ≤ P ≤ 10^6$) of the hall. Each of the following $K$ lines contains four space-separated integers $N$, $S$, $E$, and $W$ describing one carpet. The edges of the carpet are parallel to the walls and the numbers $N$, $S$, $E$, and $W$ show, respectively, the distance of the North, South, East, and West edge of the carpet from the corresponding wall. The carpets may overlap partially or fully. All distances are given in metres.

출력

The only line of output should contain a single integer $S$, the total area of the floor covered by carpets, in square metres.

예제 입력 1

2 8 9
3 3 3 0
5 1 2 4

예제 출력 1

20

예제 입력 2

3 5 5
3 1 1 3
1 3 3 1
3 1 3 1

예제 출력 2

3