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;
const long long mod = 1e9 + 7;
const int N = 1 << 20;
long long st[2 * N];
void zero(int i, int stl, int str, int l, int r) {
  if (l > str || r < stl) return;
  if (st[i] == 0) return;
  if (l <= stl && str <= r) {
    st[i] = 0;
  }
  if (stl < str) {
    int m = (stl + str) / 2;
    zero(i * 2, stl, m, l, r);
    zero(i * 2 + 1, m + 1, str, l, r);
    st[i] = (st[i * 2] + st[i * 2 + 1]) % mod;
  }
}
long long sum(int a, int b) {
  a += N;
  b += N;
  long long s = 0;
  while (a <= b) {
    if (a % 2) s += st[a++];
    if (!(b % 2)) s += st[b--];
    a /= 2;
    b /= 2;
  }
  s %= mod;
  return s;
}
void add(int i, long long v) {
  v %= mod;
  for (i += N; i; i /= 2) {
    st[i] += v;
    while (st[i] >= mod) st[i] -= mod;
  }
}
vector<pair<int, int> > sps[1010101];
vector<pair<int, int> > eps[1010101];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    sps[x1].push_back({y1, y2});
    eps[x2 + 1].push_back({y1, y2});
  }
  sps[n + 1].push_back({1, m - 1});
  set<pair<int, int> > has;
  for (int i = 1; i <= n + 1; i++) {
    if (i == 2) add(1, 1);
    sort(sps[i].rbegin(), sps[i].rend());
    for (int j = 0; j < (int)sps[i].size(); j++) {
      if (!(j > 0 && sps[i][j - 1].first == sps[i][j].second + 1)) {
        auto it = has.lower_bound({sps[i][j].second + 2, 0});
        int lo = 1;
        if (it != has.begin()) {
          it--;
          lo = (*it).second + 1;
        }
        long long v = sum(lo, sps[i][j].second);
        add(sps[i][j].second + 1, v);
      }
      zero(1, 0, N - 1, sps[i][j].first, sps[i][j].second);
    }
    for (auto e : eps[i]) {
      has.erase(e);
    }
    for (auto s : sps[i]) {
      has.insert(s);
    }
  }
  cout << sum(1, m) << endl;
}