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 mo = 1000000007;
const int M = 1000005;
const int N = 100005;
struct rect {
  int x, y, X, Y, v;
  bool operator<(const rect &a) const { return y < a.y; }
} a[N];
int n, m, k;
int t[M * 3], tg[M * 3];
vector<int> in[M], out[M];
set<pair<int, int> > S;
void clear(int k) {
  tg[k] = 1;
  t[k] = 0;
}
void pushdown(int k) {
  if (!tg[k]) return;
  clear(k * 2);
  clear(k * 2 + 1);
  tg[k] = 0;
}
void change(int k, int l, int r, int p, int v) {
  t[k] = (t[k] + v) % mo;
  if (l == r) return;
  int mid = (l + r) / 2;
  pushdown(k);
  if (p <= mid)
    change(k * 2, l, mid, p, v);
  else
    change(k * 2 + 1, mid + 1, r, p, v);
}
void clear(int k, int l, int r, int x, int y) {
  if (x <= l && r <= y) return clear(k);
  int mid = (l + r) / 2;
  pushdown(k);
  if (x <= mid) clear(k * 2, l, mid, x, y);
  if (y > mid) clear(k * 2 + 1, mid + 1, r, x, y);
  t[k] = (t[k * 2] + t[k * 2 + 1]) % mo;
}
int ask(int k, int l, int r, int x, int y) {
  if (l == x && r == y) return t[k];
  int mid = (l + r) / 2;
  pushdown(k);
  if (y <= mid) return ask(k * 2, l, mid, x, y);
  if (x > mid) return ask(k * 2 + 1, mid + 1, r, x, y);
  return (ask(k * 2, l, mid, x, mid) + ask(k * 2 + 1, mid + 1, r, mid + 1, y)) %
         mo;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = (int)(1); i <= (int)(k); i++)
    scanf("%d%d%d%d", &a[i].x, &a[i].y, &a[i].X, &a[i].Y);
  sort(a + 1, a + k + 1);
  for (int i = (int)(1); i <= (int)(k); i++) {
    in[a[i].x].push_back(i);
    out[a[i].X + 1].push_back(i);
  }
  S.insert(pair<int, int>(0, 0));
  for (int i = (int)(1); i <= (int)(n); i++) {
    for (auto j : in[i]) {
      int id = S.lower_bound(pair<int, int>(-a[j].Y - 1, 0))->second;
      if ((!id || a[id].Y + 1 <= a[j].Y) && a[j].Y != m)
        a[j].v = ask(1, 1, m, a[id].Y + 1, a[j].Y);
    }
    for (auto j : in[i]) {
      S.insert(pair<int, int>(-a[j].y, j));
      S.insert(pair<int, int>(-a[j].Y, j));
      clear(1, 1, m, a[j].y, a[j].Y);
      if (a[j].v) change(1, 1, m, a[j].Y + 1, a[j].v);
    }
    for (auto j : out[i]) {
      S.erase(pair<int, int>(-a[j].y, j));
      S.erase(pair<int, int>(-a[j].Y, j));
    }
    if (i == 1) change(1, 1, m, 1, 1);
  }
  int pr = -(S.lower_bound(pair<int, int>(-m, 0)))->first;
  printf("%d\n", ask(1, 1, m, pr + 1, m));
}