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 Max = 1e6 + 10, maxn = 1e5 + 10, mod = 1e9 + 7;
vector<int> vs[Max], ve[Max];
int rr[maxn], x1[maxn], STRANGE[maxn], x2[maxn], y2[maxn];
struct Segm {
  int val[4 * Max];
  Segm() { fill(val, val + 4 * Max, Max); }
  void add(int f, int s, int x, int l = 0, int r = Max, int id = 1) {
    if (f >= s || l >= r || s <= l || r <= f) return;
    if (f <= l && r <= s) {
      val[id] = min(val[id], x);
      return;
    }
    int mid = (l + r) >> 1;
    add(f, s, x, l, mid, 2 * id), add(f, s, x, mid, r, 2 * id + 1);
  }
  int ask(int pos, int l = 0, int r = Max, int id = 1) {
    if (r - l == 1) return val[id];
    int mid = (l + r) >> 1;
    if (pos < mid) return min(val[id], ask(pos, l, mid, 2 * id));
    return min(val[id], ask(pos, mid, r, 2 * id + 1));
  }
};
Segm segm;
struct Segs {
  int val[4 * Max];
  bool zr[4 * Max];
  void shiftzr(int l, int r, int id) {
    val[id] = 0;
    if (r - l > 1) {
      zr[2 * id] = zr[2 * id + 1] = 1;
    }
    zr[id] = 0;
  }
  void shift(int l, int r, int id) {
    if (r - l > 1) {
      int mid = (l + r) >> 1;
      if (zr[2 * id]) shiftzr(l, mid, 2 * id);
      if (zr[2 * id + 1]) shiftzr(mid, r, 2 * id + 1);
      val[2 * id] = (val[2 * id] + val[id]) % mod;
      val[2 * id + 1] = (val[2 * id + 1] + val[id]) % mod;
      val[id] = 0;
    }
    if (zr[id]) shiftzr(l, r, id);
  }
  void clr(int f, int s, int l = 0, int r = Max, int id = 1) {
    if (f >= s || l >= r) return;
    shift(l, r, id);
    if (s <= l || r <= f) return;
    if (f <= l && r <= s) {
      zr[id] = 1;
      return;
    }
    int mid = (l + r) >> 1;
    clr(f, s, l, mid, 2 * id);
    clr(f, s, mid, r, 2 * id + 1);
  }
  void add(int f, int s, int x, int l = 0, int r = Max, int id = 1) {
    if (f >= s || l >= r) return;
    shift(l, r, id);
    if (s <= l || r <= f) return;
    if (f <= l && r <= s) {
      val[id] = (val[id] + x) % mod;
      return;
    }
    int mid = (l + r) >> 1;
    add(f, s, x, l, mid, 2 * id);
    add(f, s, x, mid, r, 2 * id + 1);
  }
  int ask(int pos, int l = 0, int r = Max, int id = 1) {
    shift(l, r, id);
    if (r - l == 1) return val[id];
    int mid = (l + r) >> 1;
    if (pos < mid) return ask(pos, l, mid, 2 * id);
    return ask(pos, mid, r, 2 * id + 1);
  }
};
Segs segs;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> x1[i] >> STRANGE[i] >> x2[i] >> y2[i];
    vs[x2[i] + 1].push_back(i);
    ve[x1[i]].push_back(i);
  }
  x1[k] = 2, x2[k] = n, STRANGE[k] = 0, y2[k] = 0;
  vs[n + 1].push_back(k);
  ve[2].push_back(k);
  k++;
  for (int i = Max - 1; i >= 0; i--) {
    for (int id : vs[i]) {
      segm.add(STRANGE[id], y2[id] + 1, x1[id]);
    }
    for (int id : ve[i]) {
      rr[id] = segm.ask(y2[id] + 1);
    }
    vs[i].clear(), ve[i].clear();
  }
  for (int i = 0; i < k - 1; i++) {
    vs[STRANGE[i] - 1].push_back(i);
    ve[y2[i]].push_back(i);
  }
  ve[0].push_back(k - 1);
  segs.add(1, 2, 1);
  for (int i = 0; i < m; i++) {
    for (int id : vs[i]) {
      segs.clr(x1[id], x2[id] + 1);
    }
    vector<int> dp;
    for (int id : ve[i]) {
      dp.push_back(segs.ask(x1[id] - 1));
    }
    reverse(dp.begin(), dp.end());
    for (int id : ve[i]) {
      segs.add(x1[id], rr[id], dp.back());
      dp.pop_back();
    }
  }
  return cout << segs.ask(n) << endl, 0;
}