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 mod = 1000000007;
const int inf = 1 << 30;
struct event {
  int x, u, d, op;
} a[100002 * 2];
struct SegmentTree {
  int dat, add;
} t[1000002 * 4];
int n, m, k, i, j, f[1000002], tmp[100002], cnt;
set<pair<int, int> > s;
vector<event> v[1000002];
int read() {
  char c = getchar();
  int w = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c <= '9' && c >= '0') {
    w = w * 10 + c - '0';
    c = getchar();
  }
  return w;
}
int my_comp(const event &a, const event &b) {
  if (a.x != b.x)
    return a.x < b.x;
  else if (a.op != b.op)
    return a.op < b.op;
  else
    return a.d < b.d;
}
void update(int p) { t[p].dat = (t[p * 2].dat + t[p * 2 + 1].dat) % mod; }
void spread(int p) {
  if (t[p].add) {
    t[p * 2].dat = t[p * 2 + 1].dat = 0;
    t[p * 2].add = t[p * 2 + 1].add = 1;
    t[p].add = 0;
  }
}
void change1(int p, int l, int r, int x, int v) {
  if (l == r) {
    t[p].dat = v;
    return;
  }
  int mid = (l + r) / 2;
  spread(p);
  if (x <= mid)
    change1(p * 2, l, mid, x, v);
  else
    change1(p * 2 + 1, mid + 1, r, x, v);
  update(p);
}
void change(int p, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    t[p].dat = 0, t[p].add = 1;
    return;
  }
  int mid = (l + r) / 2;
  spread(p);
  if (ql <= mid) change(p * 2, l, mid, ql, qr);
  if (qr > mid) change(p * 2 + 1, mid + 1, r, ql, qr);
  update(p);
}
int ask(int p, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return t[p].dat;
  int mid = (l + r) / 2, ans = 0;
  spread(p);
  if (ql <= mid) ans = (ans + ask(p * 2, l, mid, ql, qr)) % mod;
  if (qr > mid) ans = (ans + ask(p * 2 + 1, mid + 1, r, ql, qr)) % mod;
  return ans;
}
int main() {
  n = read();
  m = read();
  k = read();
  for (i = 1; i <= k; i++) {
    int x1 = read(), y1 = read(), x2 = read(), y2 = read();
    a[++cnt] = (event){x1, y1, y2, 1};
    a[++cnt] = (event){x2 + 1, y1, y2, -1};
  }
  sort(a + 1, a + cnt + 1, my_comp);
  for (i = 1; i <= cnt; i++) v[a[i].x].push_back(a[i]);
  s.insert(make_pair(0, 0));
  for (i = 1; i <= n; i++) {
    for (j = 0; j < v[i].size(); j++) {
      tmp[j] = 0;
      if (v[i][j].op == 1) {
        int lim;
        set<pair<int, int> >::iterator it =
            s.lower_bound(make_pair(v[i][j].d + 1, inf));
        if (it == s.begin())
          lim = 1;
        else
          it--, lim = (*it).second + 1;
        tmp[j] = ask(1, 1, m + 1, lim, v[i][j].d + 1);
      }
    }
    for (j = 0; j < v[i].size(); j++) {
      if (v[i][j].op == -1)
        s.erase(make_pair(v[i][j].u, v[i][j].d));
      else {
        change(1, 1, m + 1, v[i][j].u, v[i][j].d);
        change1(1, 1, m + 1, v[i][j].d + 1, tmp[j]);
        s.insert(make_pair(v[i][j].u, v[i][j].d));
      }
    }
    if (i == 1) change1(1, 1, m + 1, 1, 1);
  }
  int low = 1;
  for (i = 0; i < v[n + 1].size(); i++) low = max(low, v[n + 1][i].d + 1);
  printf("%d\n", ask(1, 1, m + 1, low, m));
  return 0;
}