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;
template <typename T>
inline void read(T &s) {
  s = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) s = ((s + (s << 2)) << 1) + ch - '0', ch = getchar();
}
int n, m, k, tl;
struct Tree {
  int val;
  bool tmp;
} t[1100000 << 2];
struct Line {
  int s, e, x;
  bool opt;
  bool operator<(const Line &A) const {
    return x == A.x ? (opt == A.opt ? s > A.s : opt > A.opt) : x < A.x;
  }
  Line(int _s = 0, int _e = 0, int _x = 0, bool _opt = 0) {
    s = _s, e = _e, x = _x, opt = _opt;
  }
} ln[1100000 << 1];
multiset<int> S;
inline int Mod(int u) { return u < 1000000007 ? u : u - 1000000007; }
inline void Update(int now) {
  t[now].val = Mod(t[now << 1].val + t[now << 1 | 1].val);
}
inline void Pushdown(int now) {
  t[now << 1].val = t[now << 1 | 1].val = t[now].tmp = 0,
           t[now << 1].tmp = t[now << 1 | 1].tmp = 1;
}
inline void Change(int now, int l, int r, int q, int val) {
  if (l == r) return (void)(t[now].val = val);
  if (t[now].tmp) Pushdown(now);
  int mid = (l + r) >> 1;
  if (mid < q)
    Change(now << 1 | 1, mid + 1, r, q, val);
  else
    Change(now << 1, l, mid, q, val);
  Update(now);
}
inline void Modify(int now, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return (void)(t[now].val = 0, t[now].tmp = 1);
  if (t[now].tmp) Pushdown(now);
  int mid = (l + r) >> 1;
  if (mid < qr) Modify(now << 1 | 1, mid + 1, r, ql, qr);
  if (mid >= ql) Modify(now << 1, l, mid, ql, qr);
  Update(now);
}
inline int Query(int now, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return t[now].val;
  if (t[now].tmp) Pushdown(now);
  int mid = (l + r) >> 1, Sum = 0;
  if (mid < qr) Sum = Query(now << 1 | 1, mid + 1, r, ql, qr);
  if (mid >= ql) Sum = Mod(Sum + Query(now << 1, l, mid, ql, qr));
  return Sum;
}
inline void Build(int now, int l, int r) {
  t[now].val = t[now].tmp = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  Build(now << 1, l, mid), Build(now << 1 | 1, mid + 1, r);
}
int main() {
  read(n), read(m), read(k), Build(1, 1, m), Change(1, 1, m, 1, 1);
  for (int i = 1, sx, sy, ex, ey; i <= k; ++i)
    read(sx), read(sy), read(ex), read(ey), ln[++tl] = Line(sy, ey, sx, 1),
                                            ln[++tl] = Line(sy, ey, ex + 1, 0);
  sort(ln + 1, ln + 1 + tl), S.insert(0), S.insert(m + 1);
  Line now;
  multiset<int>::iterator it;
  for (int i = 1; i <= tl; ++i) {
    now = ln[i];
    if (now.x > n) break;
    if (now.opt) {
      if (now.x != 1) {
        it = S.upper_bound(now.e);
        if ((*it) != now.e + 1)
          --it,
              Change(1, 1, m, now.e + 1, Query(1, 1, m, (*it) + 1, now.e + 1));
      }
      Modify(1, 1, m, now.s, now.e), S.insert(now.s), S.insert(now.e);
    } else
      S.erase(S.find(now.s)), S.erase(S.find(now.e));
  }
  S.erase(m + 1), printf("%d\n", Query(1, 1, m, (*S.rbegin()) + 1, m));
  return 0;
}