시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB31121241.379%

문제

Christmas is coming! Teo has already decided to decorate his terrace.

Teo has a big rectangular-shaped terrace. It is n meters long and m meters wide. Teo has decided to decorate his terrace in a very strange way. Instead of hanging Christmas lights on the edges of his terrace, he will put them on the floor!

Teo has 2k lamps, two per each of k colours. He will put each in some position (xi, yi), where xi represents the distance from the left side of the terrace and yi from the bottom side.

Proud of how he decorated the terrace, he decided to take the rest of his day off. But soon he got bored, so he returned to the terrace. He started counting nice rectangles on the terrace. A rectangle is nice if for each colour both lamps are either inside or outside of the rectangle. If a lamp is located on the rectangle edge, it is considered to be inside of it.

The left rectangle is not nice. One blue lamp is inside the rectangle, and one is outside. The right rectangle is nice. Red and blue lamps are inside. Yellow lamps are outside.

Teo has realized that counting nice rectangles is not an easy job. He is interested in how many nice rectangles are there, whose corners have integer distances from the bottom and left sides of the terrace. All rectangles we consider are parallel with terrace sides. This is where you step in! Count the number of nice rectangles.

입력

The first line contains three integers n, m, k (1 ≤ n ≤ 150, 1 ≤ m ≤ 1 000, 0 ≤ k ≤ 200 000), the length and the width of the terrace, and the number of lamp colours.

The next k lines contain four numbers x1, y1, x2, y2 (0 ≤ x1, x2 ≤ n, 0 ≤ y1, y2 ≤ m), positions of the first and the second lamp of the i-th colour.

출력

In a single line output the number of nice rectangles.

서브태스크

번호배점제한
126

x1 = y1 = 0 for each lamp colour

212

n, m ≤ 10, k ≤ 1 000

335

m ≤ 150

437

No additional constraints.

예제 입력 1

2 2 1
0 0 1 2

예제 출력 1

3

예제 입력 2

3 3 0

예제 출력 2

36

예제 입력 3

3 3 5
0 0 0 0
0 0 1 3
0 0 3 1
1 3 3 1
1 3 3 1

예제 출력 3

7

힌트

Clarification of the first example: The image shows all nice rectangles from the first example.

채점 및 기타 정보

  • 예제는 채점하지 않는다.