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 = 2000020;
pair<int, int> a[N], b[N];
bool comp(int x, int y) { return a[x].second > a[y].second; }
int n, m, K;
vector<int> A[N], B[N];
int g[4 * N];
bool t[4 * N];
long long T[4 * N];
set<pair<int, int> > S;
set<pair<int, int> >::iterator it;
int sum(int v, int tl, int tr, int x) {
  if (tl > x || tr <= x) return 0;
  if (tl == tr - 1) return g[v];
  int xy, yy;
  xy = sum(v + v, tl, tl + tr >> 1, x);
  yy = sum(v + v + 1, tl + tr >> 1, tr, x);
  return max(xy, yy) + g[v];
}
void add(int v, int tl, int tr, int l, int r, int x) {
  if (tl >= r || tr <= l) return;
  if (l <= tl && tr <= r) {
    g[v] += x;
    return;
  }
  add(v + v, tl, tl + tr >> 1, l, r, x);
  add(v + v + 1, tl + tr >> 1, tr, l, r, x);
}
void upd1(int v) {
  if (t[v]) {
    T[v + v] = T[v + v + 1] = T[v];
    t[v + v + 1] = t[v + v] = t[v];
    t[v] = false;
  }
}
void update(int v, int tl, int tr, int l, int r, long long x) {
  if (tl >= r || tr <= l) return;
  upd1(v);
  if (l <= tl && tr <= r) {
    T[v] = x;
    t[v] = true;
    return;
  }
  update(v + v, tl, tl + tr >> 1, l, r, x);
  update(v + v + 1, tl + tr >> 1, tr, l, r, x);
  T[v] = (T[v + v] + T[v + v + 1]) % 1000000007ll;
}
long long get(int v, int tl, int tr, int l, int r) {
  if (tl >= r || tr <= l) return 0;
  upd1(v);
  if (l <= tl && tr <= r) return T[v];
  long long x, y;
  x = get(v + v, tl, tl + tr >> 1, l, r);
  y = get(v + v + 1, tl + tr >> 1, tr, l, r);
  T[v] = (T[v + v] + T[v + v + 1]) % 1000000007ll;
  return (x + y) % 1000000007ll;
}
int main() {
  scanf("%d %d %d", &m, &n, &K);
  for (int i = 0; i < K; ++i) {
    scanf("%d %d", &b[i].first, &a[i].first);
    scanf("%d %d", &b[i].second, &a[i].second);
    A[b[i].first].push_back(i);
    B[b[i].second + 1].push_back(i);
  }
  update(1, 1, n + 1, 1, 2, 1);
  B[1].push_back(K);
  a[K].second = n;
  a[K].first = 1;
  S.insert(make_pair(a[K].second, K));
  add(1, 1, n + 1, 1, n + 1, 1);
  for (int k = 1; k <= m; ++k) {
    sort(A[k].begin(), A[k].end(), comp);
    for (int i = 0; i < A[k].size(); ++i) {
      int v = A[k][i];
      int s = sum(1, 1, n + 1, a[v].second + 1);
      if (s == 0) {
        it = S.lower_bound(make_pair(a[v].second + 1, 0));
        int l = 0;
        if (it != S.begin()) {
          it--;
          l = (*it).first;
        }
        long long now = get(1, 1, n + 1, l + 1, a[v].second + 2);
        now %= 1000000007ll;
        update(1, 1, n + 1, a[v].second + 1, a[v].second + 2, now);
      }
      S.insert(make_pair(a[v].second, v));
      add(1, 1, n + 1, a[v].first, a[v].second + 1, 1);
      update(1, 1, n + 1, a[v].first, a[v].second + 1, 0);
    }
    for (int i = 0; i < B[k].size(); ++i) {
      int v = B[k][i];
      S.erase(make_pair(a[v].second, v));
      add(1, 1, n + 1, a[v].first, a[v].second + 1, -1);
    }
  }
  it = S.lower_bound(make_pair(n, 0));
  int l = 0;
  if (it != S.begin()) {
    it--;
    l = (*it).first;
  }
  long long answer = get(1, 1, n + 1, l + 1, n + 1) % 1000000007ll;
  printf("%I64d\n", answer);
}