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 maxn = 1e6 + 1500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
long long x[maxn];
long long xx[maxn];
long long y[maxn];
long long yy[maxn];
bool cmp(long long a, long long b) { return (x[a] > x[b]); }
long long fen[maxn];
void update(long long x, long long v) {
  for (x++; x < maxn; x += (x & (-x))) {
    fen[x] += v % mod;
  }
}
long long find(long long x) {
  long long ans = 0;
  for (x++; x > 0; x -= (x & (-x))) {
    ans += fen[x];
  }
  return ans;
}
bool is_in_mos(long long x) {
  long long v = find(x);
  if (v == 0) {
    return 0;
  }
  return 1;
}
vector<long long> s[maxn];
vector<long long> e[maxn];
set<long long> st;
set<long long>::iterator it;
long long seg[4 * maxn];
bool lazy[maxn * 4];
void shift(long long a) {
  if (lazy[a]) {
    lazy[2 * a] = 1;
    lazy[2 * a + 1] = 1;
    lazy[a] = 0;
    seg[2 * a] = 0;
    seg[2 * a + 1] = 0;
  }
}
long long find_seg(long long l, long long r, long long L = 0,
                   long long R = maxn, long long node = 1) {
  if (l <= L && R <= r) {
    return seg[node];
  }
  if (r <= L || R <= l) {
    return 0;
  }
  shift(node);
  long long mid = (L + R) / 2;
  return (find_seg(l, r, L, mid, 2 * node) +
          find_seg(l, r, mid, R, 2 * node + 1)) %
         mod;
}
void updates(long long x, long long v, long long l = 0, long long r = maxn,
             long long node = 1) {
  if (l + 1 == r) {
    seg[node] = v;
    return;
  }
  long long mid = (l + r) / 2;
  shift(node);
  if (x < mid) {
    updates(x, v, l, mid, 2 * node);
  } else {
    updates(x, v, mid, r, 2 * node + 1);
  }
  seg[node] = (seg[2 * node] + seg[2 * node + 1]) % mod;
}
void update0(long long l, long long r, long long L = 0, long long R = maxn,
             long long node = 1) {
  if (l <= L && R <= r) {
    lazy[node] = 1;
    seg[node] = 0;
    return;
  }
  if (r <= L || R <= l) {
    return;
  }
  long long mid = (L + R) / 2;
  shift(node);
  update0(l, r, L, mid, 2 * node);
  update0(l, r, mid, R, 2 * node + 1);
  seg[node] = (seg[2 * node] + seg[2 * node + 1]) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 0; i < k; i++) {
    cin >> x[i] >> y[i] >> xx[i] >> yy[i];
    if (x[i] == 1 && y[i] == 1) {
      cout << 0;
      return 0;
    }
    if (x[i] == n && y[i] == m) {
      cout << 0;
      return 0;
    }
    s[y[i]].push_back(i);
    e[yy[i]].push_back(i);
  }
  st.insert(0);
  updates(1, 1);
  for (auto v : s[1]) {
    long long c = x[v];
    long long cc = xx[v];
    st.insert(cc);
    update(c, 1);
    update(cc + 1, -1);
  }
  for (long long i = 1; i <= m; i++) {
    sort(s[i].begin(), s[i].end(), cmp);
  }
  for (long long i = 2; i <= m; i++) {
    for (auto v : s[i]) {
      long long cc = xx[v];
      long long res = 0;
      if (!is_in_mos(cc + 1)) {
        it = st.upper_bound(cc + 1);
        it--;
        long long q = (*it);
        res = find_seg(q + 1, cc + 2);
      }
      updates(cc + 1, res);
    }
    for (auto v : e[i - 1]) {
      long long c = x[v];
      long long cc = xx[v];
      update(c, -1);
      update(cc + 1, +1);
      st.erase(cc);
    }
    for (auto v : s[i]) {
      long long c = x[v];
      long long cc = xx[v];
      update0(c, cc + 1);
      st.insert(cc);
      update(c, 1);
      update(cc + 1, -1);
    }
  }
  it = st.end();
  it--;
  long long q = (*it);
  cout << find_seg(q + 1, n + 1);
}