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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXH = 1000000;
const int MAXW = 1000000;
const int MAXN = 100000;
const int MOD = 1000000007;
typedef struct R {
  int x1, y1, x2, y2;
} R;
int h, w, n;
int shead[MAXH], snxt[MAXN];
int thead[MAXH], tnxt[MAXN];
R r[MAXN];
int cur[MAXN], ncur;
int sval[4 * MAXW];
int slazy[4 * MAXW];
inline void inc(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}
void spush(int x) {
  if (sval[x] != -1) {
    sval[2 * x + 1] = sval[2 * x + 2] = sval[x];
    slazy[2 * x + 1] = slazy[2 * x + 2] = 0;
    sval[x] = -1;
  }
  if (slazy[x] != 0) {
    inc(slazy[2 * x + 1], slazy[x]), inc(slazy[2 * x + 2], slazy[x]);
    slazy[x] = 0;
  }
}
void sset(int x, int l, int h, int L, int H, int VAL) {
  if (h < L || l > H) return;
  if (L <= l && h <= H) {
    sval[x] = VAL, slazy[x] = 0;
    return;
  }
  spush(x);
  int m = l + (h - l) / 2;
  sset(2 * x + 1, l, m, L, H, VAL);
  sset(2 * x + 2, m + 1, h, L, H, VAL);
}
void sinc(int x, int l, int h, int L, int H, int BY) {
  if (h < L || l > H) return;
  if (L <= l && h <= H) {
    inc(slazy[x], BY);
    return;
  }
  spush(x);
  int m = l + (h - l) / 2;
  sinc(2 * x + 1, l, m, L, H, BY);
  sinc(2 * x + 2, m + 1, h, L, H, BY);
}
int sget(int x, int l, int h, int IDX) {
  if (sval[x] != -1) return sval[x] + slazy[x];
  spush(x);
  int m = l + (h - l) / 2;
  return IDX <= m ? sget(2 * x + 1, l, m, IDX) : sget(2 * x + 2, m + 1, h, IDX);
}
void run() {
  scanf("%d%d%d", &h, &w, &n);
  for (int x = (0); x < (h); ++x) shead[x] = thead[x] = -1;
  for (int i = (0); i < (n); ++i) {
    scanf("%d%d%d%d", &r[i].x1, &r[i].y1, &r[i].x2, &r[i].y2);
    --r[i].x1, --r[i].y1, --r[i].x2, --r[i].y2;
    snxt[i] = shead[r[i].x1], shead[r[i].x1] = i;
    tnxt[i] = thead[r[i].x2], thead[r[i].x2] = i;
  }
  multiset<int> have;
  have.insert(w);
  sval[0] = slazy[0] = 0;
  sset(0, 0, w - 1, 0, 0, 1);
  for (int x = (0); x < (h); ++x) {
    for (int z = shead[x]; z != -1; z = snxt[z])
      sset(0, 0, w - 1, r[z].y1, r[z].y2, 0), have.insert(r[z].y1);
    ncur = 0;
    if (x == 0)
      cur[ncur++] = 0;
    else
      for (int z = thead[x - 1]; z != -1; z = tnxt[z]) {
        if (r[z].y1 != 0) cur[ncur++] = r[z].y1 - 1;
        multiset<int>::iterator it = have.lower_bound(r[z].y1);
        have.erase(it);
      }
    sort(cur, cur + ncur);
    ncur = unique(cur, cur + ncur) - cur;
    for (int i = ncur - 1; i >= 0; --i) {
      int y = cur[i];
      int val = sget(0, 0, w - 1, y);
      if (val == 0) continue;
      multiset<int>::iterator it = have.lower_bound(y);
      int ny = *it - 1;
      if (y + 1 <= ny) sinc(0, 0, w - 1, y + 1, ny, val);
    }
  }
  int ret = sget(0, 0, w - 1, w - 1);
  printf("%d\n", ret);
}
int main() {
  run();
  return 0;
}