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;
inline int read() {
  int x = 0, c = getchar(), f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  return f ? -x : x;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
const int mo = 1e9 + 7;
const int N = 1000000 + 10;
vector<pair<int, int> > L[N], R[N];
set<pair<int, int> > Set;
int n, m, k;
int Ql, Qr, Qv, tag[N * 4], sum[N * 4];
void down(int o) {
  int &x = tag[o];
  if (x != -1) {
    tag[o << 1] = tag[o << 1 | 1] = sum[o << 1] = sum[o << 1 | 1] = x;
    x = -1;
  }
}
void modify(int o, int l, int r) {
  if (Ql <= l && Qr >= r) {
    tag[o] = sum[o] = Qv;
    return;
  }
  down(o);
  if (Ql <= ((l + r) >> 1)) modify(o << 1, l, ((l + r) >> 1));
  if (Qr > ((l + r) >> 1)) modify(o << 1 | 1, ((l + r) >> 1) + 1, r);
  sum[o] = sum[o << 1];
  if ((sum[o] += sum[o << 1 | 1]) >= mo) sum[o] -= mo;
}
int query(int o, int l, int r) {
  if (Ql > Qr) return 0;
  if (Ql <= l && Qr >= r) return sum[o];
  down(o);
  int res = 0;
  if (Ql <= ((l + r) >> 1)) res = query(o << 1, l, ((l + r) >> 1));
  if (Qr > ((l + r) >> 1))
    if ((res += query(o << 1 | 1, ((l + r) >> 1) + 1, r)) >= mo) res -= mo;
  return res;
}
int main() {
  n = read(), m = read(), k = read();
  for (int i = 1, _y = k; i <= _y; ++i) {
    int saklfjhau = read(), daiosfhas = read(), wsdkfihoq = read(),
        edqwioury = read();
    L[saklfjhau].push_back(make_pair(daiosfhas, edqwioury));
    R[wsdkfihoq + 1].push_back(make_pair(daiosfhas, edqwioury));
  }
  memset(tag, -1, sizeof(int) * (n + 5) * 4);
  Set.insert(make_pair(0, 0));
  for (int i = 0, _y = L[1].size() - 1; i <= _y; ++i) Set.insert(L[1][i]);
  Ql = Qr = Qv = 1, modify(1, 1, m);
  for (int i = 2, _y = n; i <= _y; ++i) {
    sort(L[i].begin(), L[i].end());
    for (int j = L[i].size() - 1, _y = 0; j >= _y; --j) {
      int u = L[i][j].second;
      if (u >= m) continue;
      Ql = (--Set.upper_bound(make_pair(u + 2, 0)))->second + 1, Qr = u + 1,
      Qv = query(1, 1, m);
      Ql = u + 1, Qr = u + 1, modify(1, 1, m);
    }
    for (int j = 0, _y = R[i].size() - 1; j <= _y; ++j) Set.erase(R[i][j]);
    for (int j = 0, _y = L[i].size() - 1; j <= _y; ++j) {
      Set.insert(L[i][j]);
      Ql = L[i][j].first, Qr = L[i][j].second, Qv = 0, modify(1, 1, m);
    }
  }
  Ql = Set.rbegin()->first + 1, Qr = m, printf("%d\n", query(1, 1, m));
}