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 M = 1000000007;
const int maxn = 1048576;
int N;
int n, m, k;
pair<int, int> o[maxn];
vector<pair<int, pair<int, int> > > st, en;
int cf[maxn * 2];
int s[maxn * 2];
multiset<pair<int, int> > ss;
int dp[maxn];
void rlx(int seg, int ls, int rs) {
  if (cf[seg] == -1) return;
  int mid = (ls + rs) >> 1;
  cf[(seg + seg + 1)] = cf[seg];
  s[(seg + seg + 1)] = 1ll * cf[seg] * (mid - ls) % M;
  cf[(seg + seg + 2)] = cf[seg];
  s[(seg + seg + 2)] = 1ll * cf[seg] * (rs - mid) % M;
  cf[seg] = -1;
}
void upd(int seg) { s[seg] = (s[(seg + seg + 1)] + s[(seg + seg + 2)]) % M; }
void cng(int seg, int ls, int rs, int l, int r, int first) {
  if (r <= ls or rs <= l) return;
  if (l <= ls and rs <= r) {
    cf[seg] = first;
    s[seg] = 1ll * first * (rs - ls) % M;
    return;
  }
  rlx(seg, ls, rs);
  int mid = (ls + rs) >> 1;
  cng((seg + seg + 1), ls, mid, l, r, first);
  cng((seg + seg + 2), mid, rs, l, r, first);
  upd(seg);
}
int sum(int seg, int ls, int rs, int l, int r) {
  if (r <= ls or rs <= l or r <= l) return 0;
  if (l <= ls and rs <= r) return s[seg];
  rlx(seg, ls, rs);
  int mid = (ls + rs) >> 1;
  return (sum((seg + seg + 1), ls, mid, l, r) +
          sum((seg + seg + 2), mid, rs, l, r)) %
         M;
}
void rem(int l, int r) {
  ss.erase(ss.find({r - 1, 1}));
  ss.erase(ss.find({l, 0}));
}
void add(int l, int r) {
  cng(0, 0, N, l, r, 0);
  ss.insert({r - 1, 1});
  ss.insert({l, 0});
}
int nex(int l) {
  auto P = *ss.lower_bound({l, 0});
  if (P.second) return l;
  return P.first;
}
int main() {
  memset(cf, -1, sizeof cf);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  N = m + 3;
  ss.insert({N, 0});
  for (int a, b, c, d, i = 0; i < k; i++) {
    cin >> a >> b >> c >> d;
    o[i].first = c;
    o[i].second = b;
    st.push_back({c, {b, d + 1}});
    en.push_back({a, {b, d + 1}});
  }
  o[k++] = {0, 2};
  sort(o, o + k);
  sort(st.begin(), st.end());
  sort(en.begin(), en.end());
  cng(0, 0, N, m, m + 1, 1);
  for (int i = k - 1; i >= 0;) {
    vector<int> v, d;
    int lx = o[i].first;
    for (; en.size() and en.back().first > lx + 1; en.pop_back())
      rem(en.back().second.first, en.back().second.second);
    for (; i >= 0 and o[i].first == lx; i--) {
      int r = nex(o[i].second - 1);
      if (lx != n) dp[i] = sum(0, 0, N, o[i].second - 1, r);
      v.push_back(o[i].second);
      d.push_back(dp[i]);
    }
    for (int j = 0; j < v.size(); j++) cng(0, 0, N, v[j] - 1, v[j], d[j]);
    for (; st.size() and st.back().first >= lx; st.pop_back())
      add(st.back().second.first, st.back().second.second);
  }
  cout << dp[0] << endl;
  return 0;
}