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 N = 4000005, M = 1000000;
long long sum[N + 5], tag[N + 5], n, m, k, tot, tag1[N + 5];
vector<long long> vec[M + 5], ad[M + 5], de[M + 5];
vector<pair<long long, long long> > vec1[M + 5];
set<long long> st;
struct l1 {
  long long x, y;
} bla[N + 5];
long long add(long long x) { return x >= 1000000007 ? x - 1000000007 : x; }
void push_up(long long p) { sum[p] = add(sum[p * 2] + sum[p * 2 + 1]); }
void build(long long l, long long r, long long p) {
  if (l == r) {
    if (l == 1) sum[p] = 1;
    return;
  }
  long long mid = l + r >> 1;
  build(l, mid, p * 2);
  build(mid + 1, r, p * 2 + 1);
  push_up(p);
}
void f(long long p, long long v, long long l, long long r) {
  tag[p] = add(tag[p] + v);
  sum[p] = (sum[p] + (r - l + 1) * v) % 1000000007;
}
void f1(long long p) {
  tag1[p] = 1;
  tag[p] = sum[p] = 0;
}
void push_down(long long l, long long r, long long p) {
  long long mid = l + r >> 1;
  if (tag1[p]) {
    f1(p * 2);
    f1(p * 2 + 1);
    tag1[p] = 0;
  }
  if (tag[p]) {
    f(p * 2, tag[p], l, mid);
    f(p * 2 + 1, tag[p], mid + 1, r);
    tag[p] = 0;
  }
}
void add(long long l, long long r, long long nl, long long nr, long long v,
         long long p) {
  if (l > nr || r < nl) return;
  if (nl <= l && r <= nr) {
    f(p, v, l, r);
    return;
  }
  long long mid = l + r >> 1;
  push_down(l, r, p);
  add(l, mid, nl, nr, v, p * 2);
  add(mid + 1, r, nl, nr, v, p * 2 + 1);
  push_up(p);
}
long long find(long long l, long long r, long long sit, long long p) {
  if (l == r) {
    return sum[p];
  }
  push_down(l, r, p);
  long long mid = l + r >> 1;
  if (sit <= mid)
    return find(l, mid, sit, p * 2);
  else
    return find(mid + 1, r, sit, p * 2 + 1);
}
void change(long long l, long long r, long long nl, long long nr, long long p) {
  if (l > nr || r < nl) return;
  if (nl <= l && r <= nr) {
    f1(p);
    return;
  }
  long long mid = l + r >> 1;
  push_down(l, r, p);
  change(l, mid, nl, nr, p * 2);
  change(mid + 1, r, nl, nr, p * 2 + 1);
  push_up(p);
}
int main() {
  scanf("%lld%lld%lld", &n, &m, &k);
  vec[1].push_back(1);
  for (long long i = 1; i <= k; i++) {
    long long nx, ny, mx, my;
    scanf("%lld%lld%lld%lld", &nx, &ny, &mx, &my);
    ad[ny].push_back(nx);
    de[my + 1].push_back(nx);
    if (nx != 1) vec[my + 1].push_back(nx - 1);
    vec1[ny].push_back(make_pair(nx, mx));
  }
  build(1, n, 1);
  st.insert(n + 1);
  for (long long i = 1; i <= m; i++) {
    for (long long t = 0; t < vec1[i].size(); t++) {
      change(1, n, vec1[i][t].first, vec1[i][t].second, 1);
    }
    for (long long t = 0; t < de[i].size(); t++) {
      long long x = de[i][t];
      st.erase(x);
    }
    for (long long t = 0; t < ad[i].size(); t++) {
      long long x = ad[i][t];
      st.insert(x);
    }
    sort(vec[i].begin(), vec[i].end());
    for (long long t = (long long)(vec[i].size()) - 1; t >= 0; t--) {
      long long x = vec[i][t], v = find(1, n, x, 1);
      set<long long>::iterator it = st.lower_bound(x);
      long long nex = (*it);
      if (x + 1 <= nex - 1) add(1, n, x + 1, nex - 1, v, 1);
    }
  }
  printf("%lld", find(1, n, n, 1));
}