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>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
template <int mod>
struct modint {
  int x;
  modint(int o = 0) { x = o; }
  modint &operator=(int o) { return x = o, *this; }
  modint &operator+=(modint o) {
    return x = x + o.x >= mod ? x + o.x - mod : x + o.x, *this;
  }
  modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + mod : x - o.x, *this;
  }
  modint &operator*=(modint o) { return x = 1ll * x * o.x % mod, *this; }
  modint &operator^=(int b) {
    modint a = *this, c = 1;
    for (; b; b >>= 1, a *= a)
      if (b & 1) c *= a;
    return x = c.x, *this;
  }
  modint &operator/=(modint o) { return *this *= o ^= mod - 2; }
  modint &operator+=(int o) {
    return x = x + o >= mod ? x + o - mod : x + o, *this;
  }
  modint &operator-=(int o) {
    return x = x - o < 0 ? x - o + mod : x - o, *this;
  }
  modint &operator*=(int o) { return x = 1ll * x * o % mod, *this; }
  modint &operator/=(int o) { return *this *= ((modint(o)) ^= mod - 2); }
  template <class I>
  friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  friend modint operator*(modint a, I b) {
    return a *= b;
  }
  template <class I>
  friend modint operator/(modint a, I b) {
    return a /= b;
  }
  friend modint operator^(modint a, int b) { return a ^= b; }
  friend bool operator==(modint a, int b) { return a.x == b; }
  friend bool operator!=(modint a, int b) { return a.x != b; }
  bool operator!() { return !x; }
  modint operator-() { return x ? mod - x : 0; }
};
template <int P>
ostream &operator<<(ostream &out, modint<P> &x) {
  cout << x.x;
}
modint<1000000007> val[1000005 << 2], tag[1000005 << 2];
inline void pushup(int p) { val[p] = val[p << 1] + val[p << 1 | 1]; }
inline void pusht(int p, int len, modint<1000000007> v) {
  tag[p] = v, val[p] = v * len;
}
inline void pushdown(int p, int l, int r) {
  if (tag[p] == -1) return;
  int mid = l + r >> 1;
  pusht(p << 1, mid - l + 1, tag[p]);
  pusht(p << 1 | 1, r - mid, tag[p]);
  tag[p] = -1;
}
void modify(int p, int l, int r, int nl, int nr, modint<1000000007> v) {
  if (l >= nl && r <= nr) return pusht(p, r - l + 1, v);
  int mid = l + r >> 1;
  pushdown(p, l, r);
  if (nl <= mid) modify(p << 1, l, mid, nl, nr, v);
  if (nr > mid) modify(p << 1 | 1, mid + 1, r, nl, nr, v);
  pushup(p);
}
void add(int p, int l, int r, int x, modint<1000000007> v) {
  if (l == r) return val[p] += v, void();
  int mid = l + r >> 1;
  pushdown(p, l, r);
  if (x <= mid)
    add(p << 1, l, mid, x, v);
  else
    add(p << 1 | 1, mid + 1, r, x, v);
  pushup(p);
}
modint<1000000007> ask(int p, int l, int r, int ql, int qr) {
  if (ql > qr) return 0;
  if (l >= ql && r <= qr) return val[p];
  int mid = l + r >> 1;
  modint<1000000007> res = 0;
  pushdown(p, l, r);
  if (ql <= mid) res += ask(p << 1, l, mid, ql, qr);
  if (qr > mid) res += ask(p << 1 | 1, mid + 1, r, ql, qr);
  return res;
}
int n, m, k, cnt;
multiset<int> s;
struct node {
  int x, _____, y2, op;
  bool operator<(const node &b) const {
    if (x == b.x) return op == b.op ? _____ > b._____ : op > b.op;
    return x < b.x;
  }
} a[1000005];
signed main() {
  n = read(), m = read(), k = read();
  for (register int i = (1); i <= (k); ++i) {
    int x1 = read(), _____ = read(), x2 = read(), y2 = read();
    a[++cnt] = (node){x1, _____, y2, 1};
    a[++cnt] = (node){x2 + 1, _____, y2, -1};
  }
  memset(tag, -1, sizeof tag);
  sort(a + 1, a + cnt + 1);
  modify(1, 1, m, 1, 1, 1);
  int p = 1;
  s.insert(0), s.insert(m + 1);
  while (p <= cnt && a[p].x == 1) s.insert(a[p]._____), s.insert(a[p].y2), ++p;
  while (p <= cnt && a[p].x <= n) {
    if (a[p].op == -1) {
      s.erase(s.find(a[p]._____));
      s.erase(s.find(a[p].y2));
    } else {
      multiset<int>::iterator it = s.upper_bound(a[p].y2);
      it--;
      modint<1000000007> v = ask(1, 1, m, (*it) + 1, a[p].y2);
      it = s.upper_bound(a[p].y2);
      if ((*it) != a[p].y2 + 1) add(1, 1, m, a[p].y2 + 1, v);
      modify(1, 1, m, a[p]._____, a[p].y2, 0);
      s.insert(a[p]._____), s.insert(a[p].y2);
    }
    p++;
  }
  multiset<int>::iterator it = s.lower_bound(m);
  it--;
  cout << ask(1, 1, m, (*it) + 1, m).x;
  return 0;
}