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;
struct T {
  long long x, l, r;
} c[100005], d[100005];
long long n, m, k, a[4000005], tg[4000005], b[4000005], Tg[4000005];
bool cmp(T x, T y) { return x.x == y.x ? x.l > y.l : x.x < y.x; }
void dn(long long k, long long l, long long r) {
  long long mid = l + r >> 1;
  if (tg[k]) {
    a[k << 1] += tg[k] * (mid - l + 1);
    tg[k << 1] += tg[k];
    a[k << 1 | 1] += tg[k] * (r - mid);
    tg[k << 1 | 1] += tg[k];
    tg[k] = 0;
  }
}
void mdy(long long k, long long l, long long r, long long x, long long y,
         long long p) {
  if (x <= l && r <= y) {
    a[k] += p * (r - l + 1);
    tg[k] += p;
    return;
  }
  long long mid = l + r >> 1;
  dn(k, l, r);
  if (x <= mid) mdy(k << 1, l, mid, x, y, p);
  if (y > mid) mdy(k << 1 | 1, mid + 1, r, x, y, p);
  a[k] = a[k << 1] + a[k << 1 | 1];
}
long long sum(long long k, long long l, long long r, long long x) {
  if (r <= x) return a[k];
  long long mid = l + r >> 1, ans;
  dn(k, l, r);
  ans = sum(k << 1, l, mid, x);
  if (x > mid) ans += sum(k << 1 | 1, mid + 1, r, x);
  return ans;
}
long long kth(long long k, long long l, long long r, long long x) {
  if (l == r) return l;
  long long mid = l + r >> 1;
  dn(k, l, r);
  if (a[k << 1] >= x) return kth(k << 1, l, mid, x);
  return kth(k << 1 | 1, mid + 1, r, x - a[k << 1]);
}
void down(long long k, long long l, long long r) {
  if (Tg[k]) {
    Tg[k << 1] = Tg[k << 1 | 1] = 1;
    b[k << 1] = b[k << 1 | 1] = 0;
    Tg[k] = 0;
  }
}
void add(long long k, long long l, long long r, long long x, long long y) {
  b[k] = (b[k] + y) % 1000000007;
  if (l == r) return;
  long long mid = l + r >> 1;
  down(k, l, r);
  if (x <= mid)
    add(k << 1, l, mid, x, y);
  else
    add(k << 1 | 1, mid + 1, r, x, y);
}
void gg(long long k, long long l, long long r, long long x, long long y) {
  if (x <= l && r <= y) {
    b[k] = 0;
    Tg[k] = 1;
    return;
  }
  long long mid = l + r >> 1;
  down(k, l, r);
  if (x <= mid) gg(k << 1, l, mid, x, y);
  if (y > mid) gg(k << 1 | 1, mid + 1, r, x, y);
  b[k] = (b[k << 1] + b[k << 1 | 1]) % 1000000007;
}
long long qry(long long k, long long l, long long r, long long x, long long y) {
  if (x > y) return 0;
  if (x <= l && r <= y) return b[k];
  long long mid = l + r >> 1, Ans = 0;
  down(k, l, r);
  if (x <= mid) Ans += qry(k << 1, l, mid, x, y);
  if (y > mid) Ans += qry(k << 1 | 1, mid + 1, r, x, y);
  return Ans % 1000000007;
}
int main() {
  scanf("%lld%lld%lld", &n, &m, &k);
  for (long long i = 1; i <= k; i++) {
    long long x1, y1, x2, y2;
    scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
    c[i] = (T){x1, y1, y2};
    d[i] = (T){x2, y1, y2};
  }
  sort(c + 1, c + k + 1, cmp);
  sort(d + 1, d + k + 1, cmp);
  long long now = 1, pre = 1, rnow = 1;
  for (long long i = 1; i <= n; i++) {
    if (i == 2) add(1, 1, m, 1, 1);
    while (now <= k && c[now].x == i) {
      long long t = kth(1, 0, m, sum(1, 0, m, c[now].r + 1)) + 1;
      t = qry(1, 1, m, t, c[now].r + 1);
      gg(1, 1, m, c[now].l, c[now].r + 1);
      if (c[now].r < m) add(1, 1, m, c[now].r + 1, t);
      now++;
    }
    while (rnow <= k && d[rnow].x == i - 1) {
      mdy(1, 0, m, d[rnow].l, d[rnow].r, -1);
      rnow++;
    }
    while (pre < now) {
      mdy(1, 0, m, c[pre].l, c[pre].r, 1);
      gg(1, 1, m, c[pre].l, c[pre].r);
      pre++;
    }
  }
  long long t = kth(1, 0, m, sum(1, 0, m, m)) + 1;
  printf("%lld\n", qry(1, 1, m, t, m));
}