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 long long rd() {
  long long _x = 0;
  int _ch = getchar(), _f = 1;
  for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
    ;
  if (_ch == '-') {
    _f = 0;
    _ch = getchar();
  }
  for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0';
  return _f ? _x : -_x;
}
void write(long long _x) {
  if (_x >= 10)
    write(_x / 10), putchar(_x % 10 + '0');
  else
    putchar(_x + '0');
}
inline void wrt(long long _x, char _p) {
  if (_x < 0) putchar('-'), _x = -_x;
  write(_x);
  if (_p) putchar(_p);
}
inline int Mod(int x) { return x >= 1000000007 ? x - 1000000007 : x; }
int n, m, k;
struct node {
  int x, y, h, p;
  bool operator<(const node B) const {
    return (h == B.h) ? (p == B.p ? x > B.x : p > B.p) : h < B.h;
  }
} Line[1000005 << 1];
int tot;
struct Tree {
  int sum[1000005 << 2], tag[1000005 << 2];
  void pushdown(int pos) {
    if (!tag[pos]) return;
    sum[pos << 1] = sum[pos << 1 | 1] = 0;
    tag[pos << 1] = tag[pos << 1 | 1] = 1;
    tag[pos] = 0;
  }
  void update(int pos, int l, int r, int ql, int qr) {
    if (l > qr || r < ql) return;
    if (ql <= l && r <= qr) {
      tag[pos] = 1;
      sum[pos] = 0;
      return;
    }
    pushdown(pos);
    update(pos << 1, l, ((l + r) >> 1), ql, qr),
        update(pos << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr);
    sum[pos] = Mod(sum[pos << 1] + sum[pos << 1 | 1]);
  }
  void modify(int pos, int l, int r, int x, int v) {
    if (l == r) return sum[pos] = Mod(sum[pos] + v), void();
    pushdown(pos);
    if (x <= ((l + r) >> 1))
      modify(pos << 1, l, ((l + r) >> 1), x, v);
    else
      modify(pos << 1 | 1, ((l + r) >> 1) + 1, r, x, v);
    sum[pos] = Mod(sum[pos << 1] + sum[pos << 1 | 1]);
  }
  int query(int pos, int l, int r, int ql, int qr) {
    if (l > qr || r < ql) return 0;
    if (ql <= l && r <= qr) return sum[pos];
    pushdown(pos);
    return Mod(query(pos << 1, l, ((l + r) >> 1), ql, qr) +
               query(pos << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr));
  }
} tr;
multiset<int> st;
int main() {
  n = rd(), m = rd(), k = rd();
  for (int i = int(1); i <= (int)(k); i++) {
    int x = rd(), y = rd(), xx = rd(), yy = rd();
    Line[++tot] = {y, yy, x, 1};
    Line[++tot] = {y, yy, xx + 1, 0};
  }
  sort(Line + 1, Line + 1 + tot);
  tr.modify(1, 1, m, 1, 1);
  st.insert(0), st.insert(m + 1);
  for (int i = int(1); i <= (int)(tot); i++) {
    if (Line[i].h > n) break;
    if (Line[i].p == 1) {
      multiset<int>::iterator it = st.upper_bound(Line[i].y);
      --it;
      int Sum;
      if (Line[i].h > 1)
        Sum = tr.query(1, 1, m, *it + 1, Line[i].y);
      else
        Sum = 0;
      ++it;
      if (*it != Line[i].y + 1) tr.modify(1, 1, m, Line[i].y + 1, Sum);
      tr.update(1, 1, m, Line[i].x, Line[i].y);
      st.insert(Line[i].x);
      st.insert(Line[i].y);
    } else {
      st.erase(st.find(Line[i].x));
      st.erase(st.find(Line[i].y));
    }
  }
  multiset<int>::iterator it = st.find(m + 1);
  --it;
  wrt(tr.query(1, 1, m, *it + 1, m), '\n');
}