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 maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;
struct Segment {
  int seg[maxn * 4], lazy[maxn * 4], active[maxn * 4], cnt[maxn * 4];
  void build(int s = 0, int e = maxn, int id = 1) {
    lazy[id] = active[id] = 0;
    if (e - s < 2) {
      cnt[id] = 1;
      seg[id] = 0;
      return;
    }
    int mid = (s + e) / 2;
    build(s, mid, id * 2 + 0);
    build(mid, e, id * 2 + 1);
    cnt[id] = cnt[id * 2 + 0] + cnt[id * 2 + 1];
    seg[id] = seg[id * 2 + 0] + seg[id * 2 + 1];
  }
  void add_lazy(int val, int id) {
    if (id >= 4 * maxn) return;
    if (active[id]) shift(id);
    lazy[id] = (lazy[id] + val) % mod;
    seg[id] = (seg[id] + 1ll * cnt[id] * val) % mod;
  }
  void change(int id) {
    if (id >= 4 * maxn) return;
    active[id] = 1, lazy[id] = 0, seg[id] = 0;
  }
  void shift(int id) {
    if (active[id]) {
      active[id] = 0;
      change(id * 2 + 0), change(id * 2 + 1);
    }
    if (lazy[id]) {
      add_lazy(lazy[id], id * 2 + 0);
      add_lazy(lazy[id], id * 2 + 1);
      lazy[id] = 0;
    }
  }
  void add(int l, int r, int val, int s = 0, int e = maxn, int id = 1) {
    if (l >= e || r <= s) return;
    if (l <= s && r >= e) {
      add_lazy(val, id);
      return;
    }
    shift(id);
    int mid = (s + e) / 2;
    add(l, r, val, s, mid, id * 2 + 0);
    add(l, r, val, mid, e, id * 2 + 1);
    seg[id] = (seg[id * 2 + 0] + seg[id * 2 + 1]) % mod;
  }
  void deactive(int pos, int type, int s = 0, int e = maxn, int id = 1) {
    if (pos < s || pos >= e) return;
    if (e - s < 2) {
      cnt[id] = type;
      seg[id] = seg[id] * type;
      return;
    }
    shift(id);
    int mid = (s + e) / 2;
    deactive(pos, type, s, mid, id * 2 + 0);
    deactive(pos, type, mid, e, id * 2 + 1);
    seg[id] = (seg[id * 2 + 0] + seg[id * 2 + 1]) % mod;
  }
  void set0(int l, int r, int s = 0, int e = maxn, int id = 1) {
    if (l >= e || r <= s) return;
    if (l <= s && r >= e) {
      change(id);
      return;
    }
    shift(id);
    int mid = (s + e) / 2;
    set0(l, r, s, mid, id * 2 + 0);
    set0(l, r, mid, e, id * 2 + 1);
    cnt[id] = cnt[id * 2 + 0] + cnt[id * 2 + 1];
    seg[id] = (seg[id * 2 + 0] + seg[id * 2 + 1]) % mod;
  }
  int get(int pos, int s = 0, int e = maxn, int id = 1) {
    if (pos < s || pos >= e) return 0;
    if (e - s < 2) return seg[id];
    shift(id);
    int mid = (s + e) / 2;
    return get(pos, s, mid, id * 2 + 0) + get(pos, mid, e, id * 2 + 1);
  }
};
Segment seg;
int n, m, k;
int a[maxn];
vector<int> bad[maxn];
vector<int> v1[maxn];
vector<pair<int, int> > v0[maxn];
set<int> st;
int ans;
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
  ;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int x, y, a, b;
    cin >> x >> y >> a >> b;
    bad[y].push_back(a + 1);
    bad[b + 1].push_back(x);
    v0[y].push_back({x, a + 1});
    v1[b + 1].push_back(x);
  }
  seg.build();
  seg.add(1, n + 1, 1);
  for (auto p : v0[1]) {
    seg.set0(p.first, n + 1);
    seg.deactive(p.first, 0);
    st.insert(p.first);
  }
  st.insert(n + 1);
  for (int i = 2; i <= m; i++) {
    for (int x : v1[i]) seg.deactive(x, 1), st.erase(x);
    for (pair<int, int> x : v0[i]) st.insert(x.first);
    sort(bad[i].begin(), bad[i].end());
    reverse(bad[i].begin(), bad[i].end());
    bad[i].resize(unique(bad[i].begin(), bad[i].end()) - bad[i].begin());
    for (int x : bad[i]) seg.add(x, *st.lower_bound(x), seg.get(x - 1));
    sort(v0[i].begin(), v0[i].end());
    for (auto x : v0[i]) {
      int dif = -seg.get(x.second - 1);
      seg.add(x.second, *st.lower_bound(x.second), dif);
      seg.set0(x.first, x.second);
      seg.deactive(x.first, 0);
    }
  }
  ans = (seg.get(n) % mod + mod) % mod;
  cout << ans << "\n";
  return 0;
}