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 N = 1 << 20, mod = 1e9 + 7;
template <typename T>
void rd(T &x) {
  int ch = getchar();
  x = 0;
  bool f = false;
  for (; ch < '0' || ch > '9'; ch = getchar()) f |= ch == '-';
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
void qmo(int &x) { x += x >> 31 & mod; }
int n, m, k, seg[N << 1];
vector<pair<int, int> > add[N], del[N];
set<pair<int, int> > st;
void upd(int p, int v) {
  v -= mod;
  p += N;
  while (p) {
    qmo(seg[p] += v);
    p >>= 1;
  }
}
void reset(int l, int r, int x = 1, int L = 0, int R = N - 1) {
  if (!seg[x]) return;
  if (l <= L && R <= r) seg[x] = 0;
  if (L == R) return;
  int md = L + R >> 1;
  if (l <= md) reset(l, r, x << 1, L, md);
  if (md < r) reset(l, r, x << 1 | 1, md + 1, R);
  qmo(seg[x] = seg[x << 1] + seg[x << 1 | 1] - mod);
}
int qry(int l, int r) {
  int res = 0;
  l += N;
  r += N;
  while (l <= r) {
    if (l & 1) qmo(res += seg[l++] - mod);
    if (!(r & 1)) qmo(res += seg[r--] - mod);
    l >>= 1;
    r >>= 1;
  }
  return res;
}
int main() {
  rd(n);
  rd(m);
  rd(k);
  for (int i = 0, x1, y1, x2, y2; i < k; ++i) {
    rd(x1);
    rd(y1);
    rd(x2);
    rd(y2);
    add[x1 - 1].emplace_back(y1, y2);
    del[x2].emplace_back(y1, y2);
  }
  add[n].emplace_back(1, m - 1);
  for (int i = 0; i <= n; ++i) {
    if (i == 1) upd(1, 1);
    sort(add[i].begin(), add[i].end(), greater<pair<int, int> >());
    for (int j = 0; j < add[i].size(); ++j) {
      if (!j || add[i][j - 1].first > add[i][j].second + 1) {
        auto it = st.lower_bound(make_pair(add[i][j].second + 2, 0));
        upd(add[i][j].second + 1,
            qry(it == st.begin() ? 1 : 1 + (--it)->second, add[i][j].second));
      }
      reset(add[i][j].first, add[i][j].second);
    }
    for (pair<int, int> _ : del[i]) st.erase(_);
    for (pair<int, int> _ : add[i]) st.insert(_);
  }
  printf("%d\n", qry(1, m));
}