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>
const int N = 1000050, mo = 1e9 + 7;
using namespace std;
inline int gi() {
  char ch = getchar();
  int x = 0, q = 0;
  while (ch < '0' || ch > '9') ch == '-' ? q = 1 : 0, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return q ? (-x) : x;
}
struct date {
  int l, r;
  date() {}
  date(int _l, int _r) {
    l = _l, r = _r;
    return;
  }
  bool operator<(const date &c) const { return l < c.l; }
};
multiset<date> t;
multiset<date>::iterator it;
struct data {
  int x, l, r, p;
  bool operator<(const data &c) const {
    if (x != c.x) return x < c.x;
    if (p != c.p) return p > c.p;
    return l < c.l;
  }
} q[N];
int tr[N << 2], tot, clr[N << 2];
void down(int x) {
  clr[(x << 1)] = 1, clr[(x << 1 | 1)] = 1, clr[x] = 0;
  tr[(x << 1)] = tr[(x << 1 | 1)] = 0;
  return;
}
void update(int x) {
  tr[x] = tr[(x << 1)] + tr[(x << 1 | 1)];
  if (tr[x] >= mo) tr[x] -= mo;
  return;
}
void update(int x, int l, int r, int y, int s) {
  if (l == r) {
    (tr[x] += s) %= mo;
    return;
  }
  if (clr[x]) down(x);
  int mid = (l + r) >> 1;
  if (y <= mid)
    update((x << 1), l, mid, y, s);
  else
    update((x << 1 | 1), mid + 1, r, y, s);
  return update(x);
}
void cover(int x, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    tr[x] = 0, clr[x] = 1;
    return;
  }
  if (clr[x]) down(x);
  int mid = (l + r) >> 1;
  if (ql <= mid) cover((x << 1), l, mid, ql, qr);
  if (qr > mid) cover((x << 1 | 1), mid + 1, r, ql, qr);
  return update(x);
}
int query(int x, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return tr[x];
  int mid = (l + r) >> 1, s = 0;
  if (clr[x]) down(x);
  if (ql <= mid) s += query((x << 1), l, mid, ql, qr);
  if (qr > mid) s += query((x << 1 | 1), mid + 1, r, ql, qr);
  if (s >= mo) s -= mo;
  return update(x), s;
}
int main() {
  int n = gi(), m = gi(), k = gi();
  int xl, yl, xr, yr, p = 0, s;
  date g;
  for (int i = 1; i <= k; ++i) {
    xl = gi(), yl = gi(), xr = gi(), yr = gi();
    q[++tot] = (data){xl, yl, yr, 1};
    q[++tot] = (data){xr + 1, yl, yr, 0};
  }
  sort(q + 1, q + tot + 1);
  t.insert(date(0, 0));
  for (int i = 1; i <= n; ++i) {
    while (p < tot && q[p + 1].x == i)
      if (q[p + 1].p) {
        ++p, it = t.lower_bound(date(q[p].r, q[p].r));
        if (it == t.end() || (*it).l > q[p].r) --it;
        if ((*it).r < q[p].r)
          s = query(1, 1, m, (*it).r + 1, q[p].r);
        else
          s = 0;
        ++it;
        if (it != t.end() && (*it).l == q[p].r + 1) s = 0;
        cover(1, 1, m, q[p].l, q[p].r);
        if (q[p].r < m) update(1, 1, m, q[p].r + 1, s);
        t.insert(date(q[p].l, q[p].r));
      } else
        ++p, t.erase(t.lower_bound(date(q[p].l, q[p].r)));
    if (i == 1) update(1, 1, m, 1, 1);
  }
  it = t.end(), --it;
  cout << query(1, 1, m, (*it).r + 1, m);
  return 0;
}