Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Slalom

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputLittle girl Masha likes winter sports, today she's planning to take part in slalom skiing.

The track is represented as a grid composed of *n* × *m* squares. There are rectangular obstacles at the track, composed of grid squares. Masha must get from the square (1, 1) to the square (*n*, *m*). She can move from a square to adjacent square: either to the right, or upwards. If the square is occupied by an obstacle, it is not allowed to move to that square.

One can see that each obstacle can actually be passed in two ways: either it is to the right of Masha's path, or to the left. Masha likes to try all ways to do things, so she would like to know how many ways are there to pass the track. Two ways are considered different if there is an obstacle such that it is to the right of the path in one way, and to the left of the path in the other way.

Help Masha to find the number of ways to pass the track. The number of ways can be quite big, so Masha would like to know it modulo 10^{9} + 7.

The pictures below show different ways to pass the track in sample tests.

Input

The first line of input data contains three positive integers: *n*, *m* and *k* (3 ≤ *n*, *m* ≤ 10^{6}, 0 ≤ *k* ≤ 10^{5}) — the size of the track and the number of obstacles.

The following *k* lines contain four positive integers each: *x*_{1}, *y*_{1}, *x*_{2}, *y*_{2} (1 ≤ *x*_{1} ≤ *x*_{2} ≤ *n*, 1 ≤ *y*_{1} ≤ *y*_{2} ≤ *m*) — coordinates of bottom left, and top right squares of the obstacle.

It is guaranteed that there are no obstacles at squares (1, 1) and (*n*, *m*), and no obstacles overlap (but some of them may touch).

Output

Output one integer — the number of ways to pass the track modulo 10^{9} + 7.

Examples

Input

3 3 0

Output

1

Input

4 5 1

2 2 3 4

Output

2

Input

5 5 3

2 2 2 3

4 2 5 2

4 4 4 4

Output

3

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/24/2019 02:38:40 (d2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|