Problem: Little 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 109 + 7.

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

Input

The first line of input data contains three positive integers: n, m and k (3 ≤ n, m ≤ 106, 0 ≤ k ≤ 105) — the size of the track and the number of obstacles.

The following k lines contain four positive integers each: x1, y1, x2, y2 (1 ≤ x1 ≤ x2 ≤ n, 1 ≤ y1 ≤ y2 ≤ 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 109 + 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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long int modulo = 1e9 + 7;
void anyade(long long int &a, long long int b) { a = (a + b) % modulo; }
const int primero = 1 << 20;
const int tope = 1 << 21;
long long int manerasri[tope];
int haymaneras[tope];
int obstaculo[tope];
void propaga(int pos) {
  while (pos > 1) {
    pos /= 2;
    obstaculo[pos] = obstaculo[2 * pos] or obstaculo[2 * pos + 1];
    haymaneras[pos] = haymaneras[2 * pos] or haymaneras[2 * pos + 1];
    manerasri[pos] = manerasri[2 * pos + 1];
    if (not obstaculo[2 * pos + 1]) anyade(manerasri[pos], manerasri[2 * pos]);
  }
}
void ponmaneras(int pos, long long int val, int hay) {
  pos += primero;
  manerasri[pos] = val;
  haymaneras[pos] = hay;
  propaga(pos);
}
void ponobstaculo(int pos, int val) {
  pos += primero;
  obstaculo[pos] += val;
  propaga(pos);
}
void elimina(int pos, int pospeque) {
  pos += primero;
  pospeque += primero;
  if (haymaneras[pos]) ponmaneras(pos - primero, 0, 0);
  while (pos > 1) {
    if (pos % 2 == 1 and haymaneras[pos - 1]) {
      pos--;
      while (pos < primero)
        if (haymaneras[2 * pos + 1])
          pos = 2 * pos + 1;
        else
          pos = 2 * pos;
      if (pos < pospeque) return;
      ponmaneras(pos - primero, 0, 0);
    } else
      pos /= 2;
  }
}
long long int sumale(int pos) {
  pos += primero;
  if (obstaculo[pos]) {
    return 0;
  }
  long long int s = manerasri[pos];
  while (pos > 1) {
    if (pos % 2 == 1) {
      anyade(s, manerasri[pos - 1]);
      if (obstaculo[pos - 1]) {
        return s;
      }
    }
    pos /= 2;
  }
  return s;
}
struct elem {
  int i1, i2, j, enter;
  elem() {}
  elem(int i1, int i2, int j, int enter) : i1(i1), i2(i2), j(j), enter(enter) {}
};
bool operator<(elem e1, elem e2) {
  if (e1.j < e2.j) return true;
  if (e1.j > e2.j) return false;
  if (e1.enter and not e2.enter) return e2.i1 <= e1.i2 + 1;
  if (not e1.enter and e2.enter) return e1.i1 > e2.i2 + 1;
  return e1.i1 > e2.i1;
}
int n, m, k;
vector<elem> ve;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int d = 0; d < k; d++) {
    int i1, j1, i2, j2;
    cin >> i1 >> j1 >> i2 >> j2;
    ve.push_back(elem(i1, i2, j1, 1));
    ve.push_back(elem(i1, i2, j2 + 1, 0));
  }
  sort(ve.begin(), ve.end());
  ponmaneras(1, 1, 1);
  int lasti = 0, lastj = 0;
  for (int d = 0; d < int(ve.size()) and ve[d].j <= m; d++) {
    elem &e = ve[d];
    int i1 = e.i1;
    int i2 = e.i2;
    int j = e.j;
    if (e.enter) {
      if (j == 1) {
        ponobstaculo(i1, 1);
      } else {
        if (not(lasti == i2 + 1 and lastj == j))
          ponmaneras(i2 + 1, sumale(i2 + 1), 1);
        elimina(i2, i1);
        ponobstaculo(i1, 1);
        lasti = i1;
        lastj = j;
      }
    } else {
      ponobstaculo(i1, -1);
    }
  }
  cout << sumale(n) << endl;
}