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;
struct tree {
  int sum;
  bool ling;
} t[4000010];
int n, m, k;
vector<pair<int, int> > qwq[1000010][2];
set<pair<int, int> > qaq;
set<pair<int, int> >::iterator it;
pair<int, int> fuck;
inline void lazy(int k) {
  if (t[k].ling) {
    t[k << 1].ling = t[k << 1 | 1].ling = 1;
    t[k << 1].sum = t[k << 1 | 1].sum = 0;
    t[k].ling = 0;
  }
  return;
}
inline void xg(int k, int l, int r, int mb, int v) {
  if (l == mb && r == mb) {
    t[k].sum = v;
    return;
  }
  lazy(k);
  int mid = l + r >> 1;
  if (mb >= l && mb <= mid) xg(k << 1, l, mid, mb, v);
  if (mb <= r && mb >= mid + 1) xg(k << 1 | 1, mid + 1, r, mb, v);
  t[k].sum = (t[k << 1].sum + t[k << 1 | 1].sum) % 1000000007;
  return;
}
inline void qling(int k, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    t[k].sum = 0;
    t[k].ling = 1;
    return;
  }
  lazy(k);
  int mid = l + r >> 1;
  if (ql <= mid) qling(k << 1, l, mid, ql, qr);
  if (qr >= mid + 1) qling(k << 1 | 1, mid + 1, r, ql, qr);
  t[k].sum = (t[k << 1].sum + t[k << 1 | 1].sum) % 1000000007;
  return;
}
inline int ask(int k, int l, int r, int ql, int qr) {
  if (ql > qr) return 0;
  if (ql <= l && r <= qr) return t[k].sum;
  lazy(k);
  int mid = l + r >> 1, sum = 0;
  if (ql <= mid) sum = (sum + ask(k << 1, l, mid, ql, qr)) % 1000000007;
  if (qr >= mid + 1)
    sum = (sum + ask(k << 1 | 1, mid + 1, r, ql, qr)) % 1000000007;
  return sum;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int x1, x2, y1, y2, i = 1; i <= k; i++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    qwq[x1][1].push_back(make_pair(y1, y2));
    qwq[x2 + 1][0].push_back(make_pair(y1, y2));
  }
  qaq.insert(make_pair(0, 0));
  xg(1, 1, m, 1, 1);
  for (int i = 0; i < qwq[1][1].size(); i++) qaq.insert(qwq[1][1][i]);
  for (int i = 2; i <= n; i++) {
    if (qwq[i][1].size()) {
      sort(qwq[i][1].begin(), qwq[i][1].end());
      reverse(qwq[i][1].begin(), qwq[i][1].end());
    }
    for (int j = 0; j < qwq[i][1].size(); j++) {
      int low = qwq[i][1][j].first, high = qwq[i][1][j].second;
      if (high != m) {
        it = qaq.lower_bound(make_pair(high + 2, 0));
        it--;
        fuck = *it;
        xg(1, 1, m, high + 1, ask(1, 1, m, fuck.second + 1, high + 1));
      }
    }
    for (int j = 0; j < qwq[i][0].size(); j++) qaq.erase(qwq[i][0][j]);
    for (int j = 0; j < qwq[i][1].size(); j++) {
      qaq.insert(qwq[i][1][j]);
      qling(1, 1, m, qwq[i][1][j].first, qwq[i][1][j].second);
    }
  }
  it = qaq.end();
  it--;
  fuck = *it;
  printf("%d\n", ask(1, 1, m, fuck.second + 1, m));
  return 0;
}