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>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
std::mt19937 rnd(time(NULL));
template <class T>
void cxk(T& a, T b) {
  a = a > b ? a : b;
}
template <class T>
void cnk(T& a, T b) {
  a = a < b ? a : b;
}
int pow(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % 1000000007;
    x = 1ll * x * x % 1000000007;
    y >>= 1;
  }
  return ret;
}
template <class Ta, class Tb>
void inc(Ta& a, Tb b) {
  a = a + b >= 1000000007 ? a + b - 1000000007 : a + b;
}
template <class Ta, class Tb>
void dec(Ta& a, Tb b) {
  a = a >= b ? a - b : a + 1000000007 - b;
}
struct block {
  int x1, y1, x2, y2;
} blo[100010];
struct Key {
  int x, y, i;
} key[100010];
int n, m;
int f[100010], up[100010], le[100010], st[100010];
int t[1000010];
void update(int x, int d) {
  while (x) inc(t[x], d), x -= x & -x;
}
int query(int x) {
  int r = 0;
  while (x <= 1000000) inc(r, t[x]), x += x & -x;
  return r;
}
std::vector<Key> v1[262147], v2[262147];
void prepare(int x, int l, int r) {
  if (l == r) {
    v1[x] = {key[l]}, v2[x] = {{key[l].x, up[l], l}};
    return;
  }
  prepare(x << 1, l, ((l + r) >> 1)),
      prepare(x << 1 | 1, ((l + r) >> 1) + 1, r);
  v1[x].resize(r - l + 1), v2[x].resize(r - l + 1);
  std::merge((v1[x << 1]).begin(), (v1[x << 1]).end(), (v1[x << 1 | 1]).begin(),
             (v1[x << 1 | 1]).end(), v1[x].begin(),
             [](Key a, Key b) { return a.y < b.y; });
  std::merge((v2[x << 1]).begin(), (v2[x << 1]).end(), (v2[x << 1 | 1]).begin(),
             (v2[x << 1 | 1]).end(), v2[x].begin(),
             [](Key a, Key b) { return a.y < b.y; });
}
void divide(int x, int l, int r) {
  if (l == r) return;
  divide(x << 1, l, ((l + r) >> 1));
  int i = 0, p = 0, j = 0;
  std::vector<Key>&A = v1[x << 1], &B = v1[x << 1 | 1], &C = v2[x << 1];
  while (i < A.size() || j < B.size()) {
    int min =
        std::min({i < A.size() ? A[i].y : 1e9, j < B.size() ? B[j].y : 1e9,
                  p < C.size() ? C[p].y : 1e9});
    if (C[p].y == min)
      update(C[p].x, 1000000007 - f[C[p].i]), ++p;
    else if (B[j].y == min)
      inc(f[B[j].i], query(le[B[j].i] + 1)), ++j;
    else
      update(A[i].x, f[A[i].i]), ++i;
  }
  while (p < C.size()) update(C[p].x, 1000000007 - f[C[p].i]), ++p;
  divide(x << 1 | 1, ((l + r) >> 1) + 1, r);
}
std::set<std::pair<int, int> > set;
int main() {
  int H = gi(), W = gi(), n = gi(), m = n + 2;
  for (int i = 1; i <= n; ++i)
    blo[i].x1 = gi(), blo[i].y1 = gi(), blo[i].x2 = gi(), blo[i].y2 = gi(),
    key[i] = {blo[i].x2 + 1, blo[i].y1 - 1};
  key[n + 1] = {1, 0}, key[n + 2] = {H, W};
  std::sort(key + 1, key + m + 1,
            [](Key a, Key b) { return a.x == b.x ? a.y > b.y : a.x < b.x; });
  for (int i = 1; i <= m; ++i) key[i].i = i;
  for (int i = 1; i <= m; ++i)
    if (key[i].x == 1 && key[i].y == 0) f[i] = 1;
  for (int i = 1; i <= m; ++i) st[i] = i;
  {
    std::sort(blo + 1, blo + n + 1,
              [](block a, block b) { return a.x1 > b.x1; });
    std::sort(st + 1, st + m + 1,
              [&](int a, int b) { return key[a].x > key[b].x; });
    set.clear();
    int i = 1, j = 1;
    while (i <= m || j <= n) {
      if (i <= m && (j > n || key[st[i]].x >= blo[j].x1))
        set.insert({key[st[i]].y, st[i]}), ++i;
      else {
        while (1) {
          auto it = set.lower_bound({blo[j].y1, -1});
          if (it == set.end() || it->first > blo[j].y2) break;
          le[it->second] = blo[j].x2;
          set.erase(it);
        }
        ++j;
      }
    }
  }
  {
    set.clear();
    for (int i = 1; i <= m; ++i) up[i] = 1e9;
    std::sort(blo + 1, blo + n + 1,
              [](block a, block b) { return a.y1 < b.y1; });
    std::sort(st + 1, st + m + 1,
              [&](int a, int b) { return key[a].y < key[b].y; });
    int i = 1, j = 1;
    while (i <= m || j <= n) {
      if (i <= m && (j > n || key[st[i]].y <= blo[j].y1))
        set.insert({key[st[i]].x, st[i]}), ++i;
      else {
        while (1) {
          auto it = set.lower_bound({blo[j].x1, -1});
          if (it == set.end() || it->first > blo[j].x2) break;
          up[it->second] = blo[j].y2;
          set.erase(it);
        }
        ++j;
      }
    }
  }
  prepare(1, 1, m);
  divide(1, 1, m);
  int ans = 0;
  for (int i = 1; i <= m; ++i)
    if (key[i].x == H && up[i] == 1e9) inc(ans, f[i]);
  printf("%d\n", ans);
  return 0;
}