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;
inline long long rd() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void rt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    rt(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
const int maxn = 1000005;
vector<pair<int, int> > pi[maxn], po[maxn];
set<pair<int, int> > mt;
int n, m, q;
bool zr[maxn << 2];
int sum[maxn << 2];
void pushdown(int i) {
  if (zr[i]) {
    sum[i << 1] = sum[i << 1 | 1] = 0;
    zr[i << 1] = zr[i << 1 | 1] = 1;
    zr[i] = 0;
  }
}
void pushup(int i) {
  sum[i] = sum[i << 1] + sum[i << 1 | 1],
  sum[i] -= sum[i] >= 1000000007 ? 1000000007 : 0;
}
void modify(int i, int l, int r, int ps, int v) {
  if (l == r) return void(sum[i] = v);
  pushdown(i);
  int mid = l + r >> 1;
  if (ps <= mid)
    modify(i << 1, l, mid, ps, v);
  else
    modify(i << 1 | 1, mid + 1, r, ps, v);
  pushup(i);
}
int query(int i, int l, int r, int fr, int bh) {
  if (fr > bh) return 0;
  if (l == fr && r == bh) return sum[i];
  pushdown(i);
  int mid = l + r >> 1;
  if (bh <= mid)
    return query(i << 1, l, mid, fr, bh);
  else if (fr > mid)
    return query(i << 1 | 1, mid + 1, r, fr, bh);
  else
    return (query(i << 1, l, mid, fr, mid) +
            query(i << 1 | 1, mid + 1, r, mid + 1, bh)) %
           1000000007;
}
void clear(int i, int l, int r, int fr, int bh) {
  if (l == fr && r == bh) {
    zr[i] = 1;
    sum[i] = 0;
    return;
  }
  pushdown(i);
  int mid = l + r >> 1;
  if (bh <= mid)
    clear(i << 1, l, mid, fr, bh);
  else if (fr > mid)
    clear(i << 1 | 1, mid + 1, r, fr, bh);
  else
    clear(i << 1, l, mid, fr, mid), clear(i << 1 | 1, mid + 1, r, mid + 1, bh);
  pushup(i);
}
int main() {
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= (int)q; i++) {
    int x1 = rd(), fjksdlfkasdj = rd(), x2 = rd(), fkjaskfsdfkasdlkf = rd();
    pi[x1].push_back(make_pair(fjksdlfkasdj, fkjaskfsdfkasdlkf));
    po[x2 + 1].push_back(make_pair(fjksdlfkasdj, fkjaskfsdfkasdlkf));
  }
  modify(1, 1, m, 1, 1);
  mt.insert(make_pair(0, 0));
  for (int j = 0; j <= (int)pi[1].size() - 1; j++) mt.insert(pi[1][j]);
  for (int i = 2; i <= (int)n; i++) {
    sort(pi[i].begin(), pi[i].end());
    for (int j = pi[i].size() - 1; j >= (int)0; j--) {
      int k = j;
      int bot = pi[i][k].first, top = pi[i][j].second;
      if (top < m) {
        pair<int, int> low = (*--mt.lower_bound(make_pair(top + 2, 0)));
        modify(1, 1, m, top + 1, query(1, 1, m, low.second + 1, top + 1));
      }
      j = k;
    }
    for (int j = 0; j <= (int)po[i].size() - 1; j++) mt.erase(po[i][j]);
    for (int j = 0; j <= (int)pi[i].size() - 1; j++) {
      mt.insert(pi[i][j]);
      clear(1, 1, m, pi[i][j].first, pi[i][j].second);
    }
  }
  pair<int, int> low = (*--mt.end());
  rt(query(1, 1, m, low.first + 1, m));
}