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;
int read() {
  int x = 0, sgn = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') sgn = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return x * sgn;
}
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int lz[N << 2], n, m, k;
long long val[N << 2];
vector<pair<int, int> > add[N], del[N];
set<pair<int, int> > s;
void pushdown(int o) {
  if (lz[o]) {
    lz[o << 1] = lz[o << 1 | 1] = 1;
    val[o << 1] = val[o << 1 | 1] = 0;
    lz[o] = 0;
  }
}
void update(int pos, int v, int o = 1, int l = 1, int r = m) {
  if (l == r) return val[o] = v, void();
  pushdown(o);
  int mid = l + r >> 1;
  if (pos <= mid)
    update(pos, v, o << 1, l, mid);
  else
    update(pos, v, o << 1 | 1, mid + 1, r);
  (val[o] = val[o << 1] + val[o << 1 | 1]) %= mod;
}
void clear(int xl, int xr, int o = 1, int l = 1, int r = m) {
  if (xl == l && xr == r) return val[o] = 0, lz[o] = 1, void();
  pushdown(o);
  int mid = l + r >> 1;
  if (xr <= mid)
    clear(xl, xr, o << 1, l, mid);
  else if (xl > mid)
    clear(xl, xr, o << 1 | 1, mid + 1, r);
  else
    clear(xl, mid, o << 1, l, mid), clear(mid + 1, xr, o << 1 | 1, mid + 1, r);
  (val[o] = val[o << 1] + val[o << 1 | 1]) %= mod;
}
long long query(int xl, int xr, int o = 1, int l = 1, int r = m) {
  if (xl == l && xr == r) return val[o];
  pushdown(o);
  int mid = l + r >> 1;
  if (xr <= mid)
    return query(xl, xr, o << 1, l, mid);
  else if (xl > mid)
    return query(xl, xr, o << 1 | 1, mid + 1, r);
  else
    return (query(xl, mid, o << 1, l, mid) +
            query(mid + 1, xr, o << 1 | 1, mid + 1, r)) %
           mod;
}
int main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= k; i++) {
    int x1 = read(), yyyyyyyyyy________1 = read(), x2 = read(), y2 = read();
    add[x1].push_back(pair<int, int>(yyyyyyyyyy________1, y2));
    del[x2 + 1].push_back(pair<int, int>(yyyyyyyyyy________1, y2));
  }
  s.insert(pair<int, int>(0, 0));
  for (pair<int, int> x : add[1]) s.insert(x);
  update(1, 1);
  for (int i = 2; i <= n; i++) {
    sort(add[i].begin(), add[i].end(), greater<pair<int, int> >());
    for (pair<int, int> cur : add[i]) {
      int x = cur.first, y = cur.second;
      long long ans = 0;
      if (y == m) continue;
      set<pair<int, int> >::iterator it =
          s.lower_bound(pair<int, int>(y + 2, 0));
      it--;
      if ((*it).second <= y) ans = query((*it).second + 1, y + 1) % mod;
      update(y + 1, ans);
    }
    for (pair<int, int> cur : del[i]) s.erase(cur);
    for (pair<int, int> cur : add[i])
      clear(cur.first, cur.second), s.insert(cur);
  }
  set<pair<int, int> >::iterator it = s.end();
  it--;
  long long ans = query((*it).second + 1, m);
  printf("%lld\n", ans);
  return 0;
}