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 = 1000005, mo = int(1e9) + 7;
struct node {
  int sum;
  bool zero;
} t[maxn * 4];
multiset<int> block;
vector<pair<int, int> > in[maxn], out[maxn];
vector<int> val[maxn];
int n, m, k;
void mark(int jd) {
  t[jd].sum = 0;
  t[jd].zero = 1;
}
void change(int l, int r, int p, int v, int jd) {
  if (l == r)
    t[jd].sum = v;
  else {
    int mid = l + r >> 1;
    if (t[jd].zero) mark(jd << 1), mark(jd << 1 | 1), t[jd].zero = 0;
    if (p <= mid)
      change(l, mid, p, v, jd << 1);
    else
      change(mid + 1, r, p, v, jd << 1 | 1);
    t[jd].sum = (t[jd << 1].sum + t[jd << 1 | 1].sum) % mo;
  }
}
int query(int l, int r, int i, int j, int jd) {
  if (j < l || i > r) return 0;
  if (i <= l && r <= j) return t[jd].sum;
  int mid = l + r >> 1;
  if (t[jd].zero) mark(jd << 1), mark(jd << 1 | 1), t[jd].zero = 0;
  return (query(l, mid, i, j, jd << 1) + query(mid + 1, r, i, j, jd << 1 | 1)) %
         mo;
}
void make_zero(int l, int r, int i, int j, int jd) {
  if (j < l || i > r) return;
  if (i <= l && r <= j)
    mark(jd);
  else {
    int mid = l + r >> 1;
    if (t[jd].zero) mark(jd << 1), mark(jd << 1 | 1), t[jd].zero = 0;
    make_zero(l, mid, i, j, jd << 1), make_zero(mid + 1, r, i, j, jd << 1 | 1);
    t[jd].sum = (t[jd << 1].sum + t[jd << 1 | 1].sum) % mo;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int x, y, x1, y1;
    scanf("%d%d%d%d", &x, &y, &x1, &y1);
    in[y].push_back(pair<int, int>(x, x1));
    out[y1 + 1].push_back(pair<int, int>(x, x1));
  }
  change(1, n, 1, 1, 1);
  for (int i = 0; i < in[1].size(); i++)
    block.insert(in[1][i].first), block.insert(in[1][i].second);
  for (int x = 2; x <= m; x++) {
    sort(in[x].begin(), in[x].end());
    for (int i = 0; i < in[x].size(); i++) {
      int r = in[x][i].second + 1, l = 1;
      multiset<int>::iterator it = block.upper_bound(r);
      if (it != block.begin()) it--, l = (*it) + 1;
      if (r <= n)
        val[x].push_back(query(1, n, l, r, 1));
      else
        val[x].push_back(0);
    }
    for (int i = 0; i < in[x].size(); i++) {
      int r = in[x][i].second + 1, l = 1;
      multiset<int>::iterator it = block.upper_bound(r);
      if (it != block.begin()) it--, l = (*it) + 1;
      if (r <= n) change(1, n, r, val[x][i], 1);
      make_zero(1, n, in[x][i].first, in[x][i].second, 1);
    }
    for (int i = 0; i < in[x].size(); i++)
      block.insert(in[x][i].first), block.insert(in[x][i].second);
    for (int i = 0; i < out[x].size(); i++)
      block.erase(block.find(out[x][i].first)),
          block.erase(block.find(out[x][i].second));
  }
  int l = 1;
  multiset<int>::iterator it = block.upper_bound(n);
  if (it != block.begin()) it--, l = (*it) + 1;
  printf("%d\n", query(1, n, l, n, 1));
  return 0;
}