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;
const int inf = 2e9;
const long long Inf = 1e10;
const int P = 1e9 + 7;
const int N = 100005;
const int M = 1000005;
inline long long IN() {
  long long x = 0;
  int ch = 0, f = 0;
  for (ch = getchar(); ch != -1 && (ch < 48 || ch > 57); ch = getchar())
    f = (ch == '-');
  for (; ch >= 48 && ch <= 57; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return f ? (-x) : x;
}
template <typename T>
inline int chkmin(T &a, const T &b) {
  if (b < a) return a = b, 1;
  return 0;
}
template <typename T>
inline int chkmax(T &a, const T &b) {
  if (b > a) return a = b, 1;
  return 0;
}
void renew(int &x, const int &y) {
  x += y;
  if (x >= P) x -= P;
  if (x < 0) x += P;
}
int Pow(int x, int y, int p) {
  int a = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) a = (long long)a * x % p;
  return a;
}
vector<pair<int, int> > in[M], ou[M];
int n, m, K;
int cov[M << 2], sum[M << 2], len[M << 2];
int ql, qr, qv, qans;
void Cov(int x, int y) {
  cov[x] = y;
  sum[x] = 1LL * len[x] * y % P;
}
void sep(int x) {
  if (cov[x] == -1) return;
  Cov(x << 1, cov[x]);
  Cov(x + x + 1, cov[x]);
  cov[x] = -1;
}
void A(int x, int L, int R) {
  if (ql <= L && R <= qr) {
    Cov(x, qv);
    return;
  }
  sep(x);
  int md = (L + R) >> 1;
  if (ql <= md) A(x << 1, L, md);
  if (md < qr) A(x + x + 1, md + 1, R);
  sum[x] = sum[x + x + 1];
  renew(sum[x], sum[x << 1]);
}
void Add(int l, int r, int v) {
  if (l > r) return;
  ql = l;
  qr = r;
  qv = v;
  A(1, 1, m);
}
void Q(int x, int L, int R) {
  if (ql <= L && R <= qr) {
    renew(qans, sum[x]);
    return;
  }
  sep(x);
  int md = (L + R) >> 1;
  if (ql <= md) Q(x << 1, L, md);
  if (md < qr) Q(x + x + 1, md + 1, R);
}
int Ask(int l, int r) {
  if (l > r) return 0;
  ql = l;
  qr = r;
  qans = 0;
  Q(1, 1, m);
  return qans;
}
void B(int x, int L, int R) {
  len[x] = R - L + 1;
  if (L == R) return;
  int md = (L + R) / 2;
  B(x << 1, L, md);
  B(x + x + 1, md + 1, R);
}
set<pair<int, int> > st;
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = (int)(1); i <= (int)(K); i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    in[x1].push_back(make_pair(y1, y2));
    ou[x2 + 1].push_back(make_pair(y1, y2));
  }
  B(1, 1, m);
  Add(1, 1, 1);
  for (auto v : in[1]) {
    st.insert(v);
    Add(v.first, v.second, 0);
  }
  for (int i = (int)(2); i <= (int)(n); i++) {
    static int tot, vx[N], vc[N];
    tot = 0;
    for (auto v : in[i]) {
      if (v.second + 1 > m) continue;
      auto w = st.lower_bound(make_pair(v.second + 2, 0));
      int Low = 0;
      if (w != st.begin()) {
        --w;
        Low = w->second;
      }
      ++tot;
      vc[tot] = Ask(Low + 1, v.second + 1);
      vx[tot] = v.second + 1;
    }
    for (int j = (int)(1); j <= (int)(tot); j++) Add(vx[j], vx[j], vc[j]);
    for (auto v : ou[i]) st.erase(v);
    for (auto v : in[i]) {
      st.insert(v);
      Add(v.first, v.second, 0);
    }
  }
  int Low = (st.empty()) ? (0) : ((--st.end())->second);
  cout << Ask(Low + 1, m) << endl;
  return 0;
}