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 T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 100007, __ = 1000007, mo = 1000000007;
template <typename T1, typename T2>
inline T1 ad(T1 &a, T2 b) {
  return a = a + b >= mo ? a + b - mo : a + b;
}
template <typename T1, typename T2>
inline T1 dl(T1 &a, T2 b) {
  return a = a >= b ? a - b : a - b + mo;
}
template <typename T1, typename T2>
inline T1 add(T1 a, T2 b) {
  return a + b >= mo ? a + b - mo : a + b;
}
template <typename T1, typename T2>
inline T1 del(T1 a, T2 b) {
  return a >= b ? a - b : a - b + mo;
}
struct sgt {
  static const int _t = __ << 2;
  long long t[_t];
  int tcls[_t];
  void up(int x) { t[x] = add(t[(x << 1)], t[(x << 1 | 1)]); }
  void putcls(int x) { tcls[x] = 1, t[x] = 0; }
  void dwn(int x) {
    if (tcls[x]) putcls((x << 1)), putcls((x << 1 | 1)), tcls[x] = 0;
  }
  void plant(int x, int l, int r) {
    t[x] = 0, tcls[x] = 0;
    if (l == r) return;
    plant((x << 1), l, ((l + r) >> 1)),
        plant((x << 1 | 1), ((l + r) >> 1) + 1, r), up(x);
  }
  void change(int x, int l, int r, int tar, long long d) {
    if (l == r) {
      ad(t[x], d);
      return;
    }
    dwn(x);
    if (tar <= ((l + r) >> 1))
      change((x << 1), l, ((l + r) >> 1), tar, d);
    else
      change((x << 1 | 1), ((l + r) >> 1) + 1, r, tar, d);
    up(x);
  }
  void qinxi(int x, int l, int r, int tl, int tr) {
    if (tl <= l && r <= tr) {
      putcls(x);
      return;
    }
    dwn(x);
    if (tl <= ((l + r) >> 1)) qinxi((x << 1), l, ((l + r) >> 1), tl, tr);
    if (tr > ((l + r) >> 1)) qinxi((x << 1 | 1), ((l + r) >> 1) + 1, r, tl, tr);
    up(x);
  }
  long long finder(int x, int l, int r, int tl, int tr) {
    if (tl <= l && r <= tr) return t[x];
    dwn(x);
    if (tr <= ((l + r) >> 1))
      return finder((x << 1), l, ((l + r) >> 1), tl, tr);
    if (tl > ((l + r) >> 1))
      return finder((x << 1 | 1), ((l + r) >> 1) + 1, r, tl, tr);
    return add(finder((x << 1), l, ((l + r) >> 1), tl, tr),
               finder((x << 1 | 1), ((l + r) >> 1) + 1, r, tl, tr));
  }
} t;
struct cxk {
  int xl, yl, xr, yr;
  long long val;
  cxk(int xl_ = 0, int yl_ = 0, int xr_ = 0, int yr_ = 0, long long val_ = 0) {
    xl = xl_, yl = yl_, xr = xr_, yr = yr_, val = val_;
  }
  friend int operator<(cxk a, cxk b) { return a.yl < b.yl; }
} ps[_];
int n, m, lps;
vector<int> qa[__], qd[__];
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty(), m = ty(), lps = ty();
  for (int i = 1, a, b, c, d; i <= lps; i++)
    a = ty(), b = ty(), c = ty(), d = ty(), ps[i] = cxk(a, b, c, d);
  sort(ps + 1, ps + lps + 1);
  for (int i = 1; i <= lps; i++)
    qa[ps[i].xl].emplace_back(i), qd[ps[i].xr + 1].emplace_back(i);
  set<pair<int, int>> hav;
  hav.emplace(0, 0);
  for (int i = 1; i <= n; i++) {
    for (auto a : qa[i]) {
      int b = hav.lower_bound(make_pair(-ps[a].yr - 1, 0))->second;
      if ((!b || ps[b].yr + 1 <= ps[a].yr) && ps[a].yr < m)
        ps[a].val = t.finder(1, 1, m, ps[b].yr + 1, ps[a].yr);
    }
    for (auto a : qa[i]) {
      hav.emplace(-ps[a].yl, a), hav.emplace(-ps[a].yr, a);
      t.qinxi(1, 1, m, ps[a].yl, ps[a].yr);
      if (ps[a].val) t.change(1, 1, m, ps[a].yr + 1, ps[a].val);
    }
    for (auto a : qd[i])
      hav.erase(make_pair(-ps[a].yl, a)), hav.erase(make_pair(-ps[a].yr, a));
    if (i == 1) t.change(1, 1, m, 1, 1);
  }
  int loc = hav.lower_bound(make_pair(-m, 0))->first;
  cout << t.finder(1, 1, m, -loc + 1, m) << lf;
  return 0;
}