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;
const int maxn = 1100000;
const int maxk = 110000;
const long long Mod = 1e9 + 7;
int n, m, k;
struct segment {
  long long c, flag;
} seg[maxn << 2];
void pushdown(const int x, const int l, const int r) {
  if (seg[x].flag != -1) {
    int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
    long long fl = seg[x].flag % Mod;
    seg[x].flag = -1;
    seg[lc].c = (long long)(mid - l + 1) * fl % Mod;
    seg[lc].flag = fl;
    seg[rc].c = (long long)(r - mid) * fl % Mod;
    seg[rc].flag = fl;
  }
}
void pushup(const int x) {
  int lc = x << 1, rc = lc | 1;
  seg[x].c = (seg[lc].c + seg[rc].c) % Mod;
}
int lx, rx;
long long v;
void upd(const int x, const int l, const int r) {
  if (rx < l || r < lx) return;
  if (lx <= l && r <= rx) {
    seg[x].c = (long long)(r - l + 1) * v % Mod;
    seg[x].flag = v;
    return;
  }
  pushdown(x, l, r);
  int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
  upd(lc, l, mid);
  upd(rc, mid + 1, r);
  pushup(x);
}
void add(const int x, const int l, const int r) {
  if (l == r) {
    seg[x].c += v;
    return;
  }
  int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
  pushdown(x, l, r);
  if (lx <= mid)
    add(lc, l, mid);
  else
    add(rc, mid + 1, r);
  pushup(x);
}
void cal(const int x, const int l, const int r) {
  if (rx < l || r < lx) return;
  if (lx <= l && r <= rx) {
    v += seg[x].c;
    return;
  }
  int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
  pushdown(x, l, r);
  cal(lc, l, mid);
  cal(rc, mid + 1, r);
}
struct D {
  int pos, x1, x2, i;
  D() {}
  D(const int _pos, const int _x1, const int _x2, const int _i) {
    pos = _pos;
    x1 = _x1;
    x2 = _x2;
    i = _i;
  }
} a[maxk << 1];
int cnt;
inline bool cmp(const D x, const D y) {
  if (x.pos == y.pos) return x.i == y.i ? x.x1 > y.x1 : x.i > y.i;
  return x.pos < y.pos;
}
multiset<int> S;
multiset<int>::iterator it;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    a[++cnt] = D(x1, y1, y2, 1);
    a[++cnt] = D(x2 + 1, y1, y2, -1);
  }
  sort(a + 1, a + cnt + 1, cmp);
  lx = rx = 1;
  v = 1ll;
  upd(1, 1, m);
  int pos = 1;
  S.insert(0);
  S.insert(m + 1);
  while (pos <= cnt && a[pos].pos == 1) {
    S.insert(a[pos].x1);
    S.insert(a[pos].x2);
    pos++;
  }
  for (int i = 2; i <= n; i++) {
    while (pos <= cnt && a[pos].pos == i) {
      if (a[pos].i == 1) {
        it = S.upper_bound(a[pos].x2);
        it--;
        lx = (*it) + 1, rx = a[pos].x2;
        v = 0ll;
        if (lx <= rx) cal(1, 1, m);
        v %= Mod;
        it = S.upper_bound(a[pos].x2);
        if ((*it) != a[pos].x2 + 1) lx = rx = a[pos].x2 + 1, add(1, 1, m);
        lx = a[pos].x1, rx = a[pos].x2, v = 0ll, upd(1, 1, m);
        S.insert(a[pos].x1);
        S.insert(a[pos].x2);
      } else {
        it = S.find(a[pos].x1);
        S.erase(it);
        it = S.find(a[pos].x2);
        S.erase(it);
      }
      pos++;
    }
  }
  it = S.lower_bound(m);
  it--;
  lx = (*it) + 1, rx = m, v = 0;
  if (lx <= rx) cal(1, 1, m);
  printf("%I64d\n", v % Mod);
  return 0;
}