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 long long mod = 1e9 + 7;
long long T[1 << 21];
char C[1 << 21];
int n, m, k;
void pushdown(int rt) {
  if (C[rt]) {
    C[rt << 1] = C[rt << 1 | 1] = 1;
    T[rt << 1] = T[rt << 1 | 1] = 0;
    C[rt] = 0;
  }
}
void update_val(int rt, int l, int r, int x, long long val) {
  if (l == r) {
    T[rt] = (T[rt] + val) % mod;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (x <= m)
    update_val(rt << 1, l, m, x, val);
  else
    update_val(rt << 1 | 1, m + 1, r, x, val);
  T[rt] = (T[rt << 1] + T[rt << 1 | 1]) % mod;
}
void update_val(int x, long long val) { update_val(1, 0, m + 1, x, val); }
long long get_sum(int rt, int l, int r, int s, int e) {
  if (s <= l && r <= e) return T[rt];
  pushdown(rt);
  int m = (l + r) >> 1;
  long long res = 0;
  if (s <= m) res = (res + get_sum(rt << 1, l, m, s, e)) % mod;
  if (m < e) res = (res + get_sum(rt << 1 | 1, m + 1, r, s, e)) % mod;
  return res;
}
long long get_sum(int s, int e) { return get_sum(1, 0, m + 1, s, e); }
void update_zero(int rt, int l, int r, int s, int e) {
  if (s <= l && r <= e) {
    C[rt] = 1;
    T[rt] = 0;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (s <= m) update_zero(rt << 1, l, m, s, e);
  if (m < e) update_zero(rt << 1 | 1, m + 1, r, s, e);
  T[rt] = (T[rt << 1] + T[rt << 1 | 1]) % mod;
}
void update_zero(int s, int e) { update_zero(1, 0, m + 1, s, e); }
vector<pair<int, int> > A[1 << 20], D[1 << 20];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k + 1; i++) {
    int x1, y1, x2, y2;
    if (i <= k)
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    else
      x1 = x2 = n + 1, y1 = 1, y2 = m - 1;
    A[x1].push_back(pair<int, int>(y1, y2));
    D[x2].push_back(pair<int, int>(y1, y2));
  }
  ++n;
  set<pair<int, int> > Seg;
  update_val(1, 1);
  for (pair<int, int> e : A[1]) Seg.insert(e);
  for (int i = 2; i <= n; i++) {
    sort(A[i].begin(), A[i].end());
    int na = (int)A[i].size();
    for (int j = na - 1; j >= 0; j--) {
      int can_upd = 1;
      if (j != na - 1 && A[i][j + 1].first == A[i][j].second + 1) can_upd = 0;
      int Y = A[i][j].second + 1, LY = 1;
      auto it = Seg.upper_bound(pair<int, int>(Y + 1, -1));
      if (it != Seg.begin()) {
        --it;
        LY = it->second + 1;
      }
      if (LY >= Y) can_upd = 0;
      if (can_upd) {
        long long val = get_sum(LY, Y - 1);
        update_val(Y, val);
      }
      update_zero(A[i][j].first, A[i][j].second);
    }
    for (pair<int, int> e : D[i - 1]) Seg.erase(e);
    for (pair<int, int> e : A[i]) Seg.insert(e);
  }
  long long ans = get_sum(m, m);
  printf("%lld\n", ans);
  return 0;
}