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 P = 1e9 + 7, N = 1e6 + 100;
int n, m, K, tag[N << 2], sum[N << 2];
set<pair<int, int> > S;
vector<pair<int, int> > vec[N];
void down(int k) {
  if (!(~tag[k])) return;
  tag[(k << 1)] = sum[(k << 1)] = tag[(k << 1 | 1)] = sum[(k << 1 | 1)] = 0,
            tag[k] = -1;
}
void cover(int k, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    tag[k] = sum[k] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  down(k);
  if (ql <= mid) cover((k << 1), l, mid, ql, qr);
  if (qr > mid) cover((k << 1 | 1), mid + 1, r, ql, qr);
  sum[k] = (sum[(k << 1)] + sum[(k << 1 | 1)]) % P;
}
void mdf(int k, int l, int r, int tar, int val) {
  if (l == r) {
    tag[k] = -1, sum[k] = val;
    return;
  }
  int mid = (l + r) >> 1;
  down(k);
  tar <= mid ? mdf((k << 1), l, mid, tar, val)
             : mdf((k << 1 | 1), mid + 1, r, tar, val);
  sum[k] = (sum[(k << 1)] + sum[(k << 1 | 1)]) % P;
}
int qry(int k, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return sum[k];
  int mid = (l + r) >> 1, res = 0;
  down(k);
  if (ql <= mid) res = qry((k << 1), l, mid, ql, qr);
  if (qr > mid) res = (res + qry((k << 1 | 1), mid + 1, r, ql, qr)) % P;
  return res;
}
int main() {
  cin >> n >> m >> K;
  for (int i = 1; i <= K; ++i) {
    int xl, yl, xr, yr;
    cin >> xl >> yl >> xr >> yr;
    vec[xl].push_back(pair<int, int>(yl, yr));
    vec[xr + 1].push_back(pair<int, int>(-yl, -yr));
    if (xl == 1) S.insert(pair<int, int>(yl, yr));
  }
  vec[n + 1].push_back(pair<int, int>(1, m - 1));
  S.insert(pair<int, int>(0, 0));
  mdf(1, 1, m, 1, 1);
  static pair<int, int> stk[N];
  int top = 0;
  for (int i = 2; i <= n + 1; ++i) {
    for (auto t : vec[i])
      if (t.first > 0 && t.first < m) {
        int x = t.second + 1;
        auto it = S.lower_bound(pair<int, int>(x + 1, 0));
        int val = 0;
        if (it != S.begin() && prev(it)->second < x)
          val = qry(1, 1, m, prev(it)->second + 1, x);
        stk[++top] = pair<int, int>(x, val);
      }
    while (top) mdf(1, 1, m, stk[top].first, stk[top].second), --top;
    for (auto t : vec[i])
      if (t.first < 0) S.erase(pair<int, int>(-t.first, -t.second));
    for (auto t : vec[i])
      if (t.first > 0) cover(1, 1, m, t.first, t.second), S.insert(t);
  }
  printf("%d\n", sum[1]);
  return 0;
}