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>
inline int read() {
  int data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
  return data * w;
}
const int N(1e6 + 10), Mod(1e9 + 7);
inline int upd(const int &x) { return x + (x >> 31 & Mod); }
struct node {
  int l, r, op;
};
inline int operator<(const node &a, const node &b) {
  return a.op == b.op ? a.l > b.l : a.op < b.op;
}
std::set<std::pair<int, int> > S;
std::vector<node> v[N];
int n, m, K, sum[N << 2], tag[N << 2];
void pushtag(int x) { tag[x] = 1, sum[x] = 0; }
void Modify(int p, int v, int x = 1, int l = 1, int r = n) {
  if (l == r) return (void)(sum[x] = v);
  int mid = (l + r) >> 1, ls = x << 1, rs = ls | 1;
  if (tag[x]) pushtag(ls), pushtag(rs), tag[x] = 0;
  if (p <= mid)
    Modify(p, v, ls, l, mid);
  else
    Modify(p, v, rs, mid + 1, r);
  sum[x] = upd(sum[ls] + sum[rs] - Mod);
}
void Assign(int ql, int qr, int x = 1, int l = 1, int r = n) {
  if (ql <= l && r <= qr) return pushtag(x);
  int mid = (l + r) >> 1, ls = x << 1, rs = ls | 1;
  if (tag[x]) pushtag(ls), pushtag(rs), tag[x] = 0;
  if (ql <= mid) Assign(ql, qr, ls, l, mid);
  if (mid < qr) Assign(ql, qr, rs, mid + 1, r);
  sum[x] = upd(sum[ls] + sum[rs] - Mod);
}
int Query(int ql, int qr, int x = 1, int l = 1, int r = n) {
  if (ql > qr) return 0;
  if (ql <= l && r <= qr) return sum[x];
  int mid = (l + r) >> 1, ls = x << 1, rs = ls | 1, ans = 0;
  if (tag[x]) pushtag(ls), pushtag(rs), tag[x] = 0;
  if (ql <= mid) ans = Query(ql, qr, ls, l, mid);
  if (mid < qr) ans = upd(ans + Query(ql, qr, rs, mid + 1, r) - Mod);
  return ans;
}
int main() {
  n = read(), m = read(), K = read();
  for (int i = 1, x_1, y_1, x_2, y_2; i <= K; i++)
    x_1 = read(), y_1 = read(), x_2 = read(), y_2 = read(),
    v[y_1].push_back((node){x_1, x_2, 1}),
    v[y_2 + 1].push_back((node){x_1, x_2, -1});
  for (int i = 1; i <= m; i++) std::sort(v[i].begin(), v[i].end());
  Modify(1, 1);
  for (auto i : v[1]) S.emplace(i.l, i.r);
  for (int i = 2; i <= m; i++) {
    for (auto j : v[i])
      if (j.op > 0) {
        int ql, qr = j.r + 1;
        auto it = S.lower_bound(std::make_pair(j.r + 1, 1e9));
        if (it == S.begin())
          ql = 1;
        else
          ql = std::prev(it)->second + 1;
        Modify(qr, Query(ql, qr));
      }
    for (auto j : v[i])
      if (j.op == -1)
        S.erase(std::make_pair(j.l, j.r));
      else
        S.emplace(j.l, j.r), Assign(j.l, j.r);
  }
  int pos = 1;
  for (auto i : v[m + 1]) pos = std::max(pos, i.r + 1);
  printf("%d\n", Query(pos, n));
  return 0;
}