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;
inline int read() {
  register int data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    data = (data << 1) + (data << 3) + (ch ^ 48), ch = getchar();
  return data * w;
}
int n, m, K;
const int mod = 1e9 + 7;
void fix(int &x) {
  x -= mod;
  x += x >> 31 & mod;
}
struct Seg {
  bool cle[4000005];
  int sum[4000005];
  void pushup(int x) { fix(sum[x] = sum[x << 1] + sum[x << 1 | 1]); }
  void Clean(int x) {
    cle[x] = 1;
    sum[x] = 0;
  }
  void pushdown(int x) {
    if (cle[x]) Clean(x << 1), Clean(x << 1 | 1);
    cle[x] = 0;
  }
  void Cels(int x, int l, int r, int ql, int qr) {
    int mid = (l + r) >> 1;
    if (ql <= l && r <= qr) return Clean(x);
    pushdown(x);
    if (ql <= mid) Cels(x << 1, l, mid, ql, qr);
    if (mid < qr) Cels(x << 1 | 1, mid + 1, r, ql, qr);
    pushup(x);
  }
  void Modify(int x, int l, int r, int pos, int v) {
    if (l == r) return fix(sum[x] += v);
    pushdown(x);
    int mid = (l + r) >> 1;
    (pos <= mid) ? Modify(x << 1, l, mid, pos, v)
                 : Modify(x << 1 | 1, mid + 1, r, pos, v);
    pushup(x);
  }
  void Modify(int pos, int v) { return Modify(1, 1, m, pos, v); }
  int Query(int x, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return sum[x];
    pushdown(x);
    int mid = (l + r) >> 1, ans = 0;
    if (ql <= mid) ans = Query(x << 1, l, mid, ql, qr);
    if (mid < qr) fix(ans += Query(x << 1 | 1, mid + 1, r, ql, qr));
    return ans;
  }
  int ask(int l, int r) { return (l > r) ? 0 : Query(1, 1, m, l, r); }
} T;
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
struct ivar {
  int x, y1, y2, tp;
} t[4000005];
int main() {
  n = read(), m = read(), K = read();
  int cnt = 0;
  for (int i = 1; i <= K; i++) {
    int x_1 = read(), y_1 = read(), x_2 = read(), y_2 = read();
    t[++cnt] = (ivar){x_1, y_1, y_2, 0};
    t[++cnt] = (ivar){x_2 + 1, y_1, y_2, 1};
  }
  sort(t + 1, t + cnt + 1,
       [](ivar A, ivar B) { return A.x != B.x ? A.x < B.x : A.y1 > B.y1; });
  T.Modify(1, 1);
  int p = 1;
  for (int i = p; t[i].x == 1; p = ++i) s.insert(make_pair(t[i].y1, t[i].y2));
  s.insert(make_pair(0, 0));
  for (int i = 2; i <= n; i++) {
    for (int j = p; t[j].x == i; ++j)
      if (t[j].tp == 0)
        if (t[j].y2 < m) {
          pair<int, int> loc = *--s.lower_bound(make_pair(t[j].y2 + 2, 0));
          int tmp = T.ask(loc.second + 1, t[j].y2);
          if (tmp) T.Modify(t[j].y2 + 1, tmp);
        }
    for (int j = p; t[j].x == i; ++j)
      if (t[j].tp == 1) s.erase(make_pair(t[j].y1, t[j].y2));
    for (int j = p; t[j].x == i; p = ++j)
      if (t[j].tp == 0)
        s.insert(make_pair(t[j].y1, t[j].y2)),
            T.Cels(1, 1, m, t[j].y1, t[j].y2);
  }
  pair<int, int> loc = *--s.end();
  cout << T.ask(loc.second + 1, m) << '\n';
  return 0;
}