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;
int n, m, k;
long long mod = 1e9 + 7;
struct ZA {
  int shang, xia, ks, js;
} za[100010];
struct TREE {
  long long zh, bj;
} tr[5000010], tr1[5000010];
bool gz(ZA x, ZA y) {
  if (x.ks == y.ks) {
    return x.shang > y.shang;
  }
  return x.ks < y.ks;
}
void bjxc1(int p, int ls, int rs) {
  if (tr1[p].bj == 0) return;
  tr1[p].bj = 0;
  tr1[ls].zh = 0;
  tr1[ls].bj = 1;
  tr1[rs].zh = 0;
  tr1[rs].bj = 1;
}
void xg1(int l, int r, int p, int wz, long long val) {
  if (l == r && l == wz) {
    tr1[p].zh += val;
    if (tr1[p].zh >= mod) tr1[p].zh -= mod;
    return;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc1(p, ls, rs);
  if (wz <= mid)
    xg1(l, mid, ls, wz, val);
  else
    xg1(mid + 1, r, rs, wz, val);
  tr1[p].zh = tr1[ls].zh + tr1[rs].zh;
  if (tr1[p].zh >= mod) tr1[p].zh -= mod;
  return;
}
void xgg1(int l, int r, int p, int ll, int rr) {
  if (ll <= l && r <= rr) {
    tr1[p].bj = 1;
    tr1[p].zh = 0;
    return;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc1(p, ls, rs);
  if (ll <= mid) xgg1(l, mid, ls, ll, rr);
  if (rr > mid) xgg1(mid + 1, r, rs, ll, rr);
  tr1[p].zh = tr1[ls].zh + tr1[rs].zh;
  if (tr1[p].zh >= mod) tr1[p].zh -= mod;
  return;
}
long long cx1(int l, int r, int p, int ll, int rr) {
  if (ll <= l && r <= rr) {
    return tr1[p].zh;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  long long jgg = 0;
  bjxc1(p, ls, rs);
  if (ll <= mid) {
    jgg += cx1(l, mid, ls, ll, rr);
    if (jgg >= mod) jgg -= mod;
  }
  if (rr > mid) {
    jgg += cx1(mid + 1, r, rs, ll, rr);
    if (jgg >= mod) jgg -= mod;
  }
  return jgg;
}
void bjxc(int p, int ls, int rs, int l, int r, int mid) {
  tr[ls].bj += tr[p].bj;
  tr[ls].zh += tr[p].bj * (mid - l + 1);
  tr[rs].bj += tr[p].bj;
  tr[rs].zh += tr[p].bj * (r - mid);
  tr[p].bj = 0;
  return;
}
void xg(int l, int r, int p, int ll, int rr, long long val) {
  if (ll <= l && r <= rr) {
    tr[p].bj += val;
    tr[p].zh += (r - l + 1) * val;
    return;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc(p, ls, rs, l, r, mid);
  if (ll <= mid) xg(l, mid, ls, ll, rr, val);
  if (rr > mid) xg(mid + 1, r, rs, ll, rr, val);
  tr[p].zh = tr[ls].zh + tr[rs].zh;
  return;
}
long long cx(int l, int r, int p, int ll, int rr) {
  if (ll <= l && r <= rr) {
    return tr[p].zh;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  long long jgg = 0;
  bjxc(p, ls, rs, l, r, mid);
  if (ll <= mid) jgg += cx(l, mid, ls, ll, rr);
  if (rr > mid) jgg += cx(mid + 1, r, rs, ll, rr);
  return jgg;
}
int cxqq(int l, int r, int p, long long nw, long long val) {
  if (l == r) {
    return l;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc(p, ls, rs, l, r, mid);
  if (nw + tr[ls].zh >= val) {
    return cxqq(l, mid, ls, nw, val);
  } else {
    return cxqq(mid + 1, r, rs, nw + tr[ls].zh, val);
  }
}
priority_queue<pair<int, int> > q;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d%d", &za[i].ks, &za[i].xia, &za[i].js, &za[i].shang);
    za[i].ks += 2;
    za[i].js += 2;
  }
  k += 2;
  n += 3;
  za[k].ks = za[k].js = n;
  za[k].xia = 1;
  za[k].shang = m - 1;
  za[k - 1].ks = za[k - 1].js = 2;
  za[k - 1].xia = 2;
  za[k - 1].shang = m;
  sort(za + 1, za + k + 1, gz);
  xg1(1, m, 1, 1, 1);
  for (int i = 1; i <= k; i++) {
    while (!q.empty()) {
      int id = q.top().second;
      if (-q.top().first < za[i].ks - 1) {
        xg(1, m, 1, za[id].xia, za[id].shang, -1);
        q.pop();
      } else {
        break;
      }
    }
    long long emm, qq;
    if (za[i].shang != m) {
      emm = cx(1, m, 1, 1, za[i].shang + 1);
      qq = cxqq(1, m, 1, 0, emm);
      if (emm == 0) qq = 0;
    }
    if (za[i].shang != m && qq < za[i].shang) {
      long long qw = cx1(1, m, 1, qq + 1, za[i].shang);
      xg1(1, m, 1, za[i].shang + 1, qw);
    }
    xg(1, m, 1, za[i].xia, za[i].shang, 1);
    xgg1(1, m, 1, za[i].xia, za[i].shang);
    q.push(make_pair(-za[i].js, i));
  }
  printf("%lld", tr1[1].zh);
  return 0;
}