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;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
int lz[1000035 * 4], T[1000035 * 4];
void Up(int rt, int l, int r) {
  T[rt] = (T[(rt << 1)] + T[(rt << 1 | 1)]) % 1000000007;
}
void Down(int rt, int l, int r) {
  if (lz[rt] != 0) {
    T[(rt << 1)] = T[(rt << 1 | 1)] = 0;
    lz[(rt << 1)] = lz[(rt << 1 | 1)] = 1;
    lz[rt] = 0;
  }
}
void upt(int rt, int l, int r, int L, int R, int val) {
  if (R <= l || r <= L) return;
  if (L <= l && r <= R) {
    T[rt] = val;
    return;
  }
  Down(rt, l, r);
  int mid = (l + r) / 2;
  upt((rt << 1), l, mid, L, R, val);
  upt((rt << 1 | 1), mid, r, L, R, val);
  Up(rt, l, r);
}
int qy(int rt, int l, int r, int L, int R) {
  if (R <= l || r <= L) return 0;
  if (L <= l && r <= R) {
    return T[rt];
  }
  Down(rt, l, r);
  int mid = (l + r) / 2;
  return (qy((rt << 1), l, mid, L, R) + qy((rt << 1 | 1), mid, r, L, R)) %
         1000000007;
}
void clr(int rt, int l, int r, int L, int R) {
  if (R <= l || r <= L) return;
  if (L <= l && r <= R) {
    T[rt] = 0;
    lz[rt] = 1;
    return;
  }
  Down(rt, l, r);
  int mid = (l + r) / 2;
  clr((rt << 1), l, mid, L, R);
  clr((rt << 1 | 1), mid, r, L, R);
  Up(rt, l, r);
}
vector<int> in[1000035], out[1000035];
set<pair<int, int> > s;
struct mb {
  int x, y, X, Y, v, id;
  bool operator<(const mb &o) const { return y < o.y; }
  void rd(int i) {
    scanf("%d%d%d%d", &x, &y, &X, &Y);
    id = i;
  }
} q[1000035];
void fmain() {
  scanf("%d%d%d", &n, &m, &k);
  for (int(i) = 1; (i) <= (int)(k); (i)++) q[i].rd(i);
  sort(q + 1, q + 1 + k);
  for (int(i) = 1; (i) <= (int)(k); (i)++) {
    in[q[i].x].push_back(i);
    out[q[i].X + 1].push_back(i);
  }
  s.insert({0, 0});
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    if (!in[i].empty()) {
      int N = in[i].size();
      for (int(j) = 0; (j) < (int)(N); (j)++) {
        int id = in[i][j];
        auto it = s.lower_bound({q[id].Y + 1, 0});
        if (it != s.end() && (*it).first == q[id].Y + 1) {
          q[id].v = -1;
          continue;
        }
        it--;
        int id2 = (*it).second;
        if (q[id2].Y <= q[id].Y && q[id].Y < m) {
          q[id].v = qy(1, 0, m, q[id2].Y, q[id].Y + 1);
        } else
          q[id].v = -1;
      }
      for (int(j) = 0; (j) < (int)(N); (j)++) {
        int id = in[i][j];
        if (q[id].v >= 0) upt(1, 0, m, q[id].Y, q[id].Y + 1, q[id].v);
        clr(1, 0, m, q[id].y - 1, q[id].Y);
        s.insert({q[id].y, id});
        s.insert({q[id].Y, id});
      }
    }
    if (!out[i].empty()) {
      int N = out[i].size();
      for (int(j) = 0; (j) < (int)(N); (j)++) {
        int id = out[i][j];
        s.erase({q[id].y, id});
        s.erase({q[id].Y, id});
      }
    }
    if (i == 1) upt(1, 0, m, 0, 1, 1);
  }
  int z = (*s.rbegin()).first;
  int Ans = qy(1, 0, m, z, m);
  printf("%d\n", Ans);
}
int main() {
  int t = 1;
  while (t--) fmain();
  return 0;
}