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>
const int N = 1000000 + 10, mod = 1e9 + 7;
struct node {
  int sum, zero;
  void mark() {
    zero = true;
    sum = 0;
  }
} T[N << 2];
void update(int rt) { T[rt].sum = (T[rt << 1].sum + T[rt << 1 | 1].sum) % mod; }
void pushdown(int rt) {
  if (T[rt].zero) {
    T[rt << 1].mark();
    T[rt << 1 | 1].mark();
    T[rt].zero = 0;
  }
}
void build(int rt, int l, int r) {
  T[rt].zero = T[rt].sum = 0;
  if (l + 1 == r) return;
  int m = (l + r) >> 1;
  build(rt << 1, l, m);
  build(rt << 1 | 1, m, r);
}
void set(int rt, int l, int r, int x, int v) {
  if (l + 1 == r) {
    T[rt].sum = v;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (x < m)
    set(rt << 1, l, m, x, v);
  else
    set(rt << 1 | 1, m, r, x, v);
  update(rt);
}
int sum(int rt, int l, int r, int L, int R) {
  if (L <= l && R >= r) return T[rt].sum;
  pushdown(rt);
  int ret = 0, m = (l + r) >> 1;
  if (L < m) ret += sum(rt << 1, l, m, L, R);
  if (R > m) ret += sum(rt << 1 | 1, m, r, L, R);
  return ret % mod;
}
void clear(int rt, int l, int r, int L, int R) {
  if (L <= l && R >= r) {
    T[rt].mark();
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (L < m) clear(rt << 1, l, m, L, R);
  if (R > m) clear(rt << 1 | 1, m, r, L, R);
  update(rt);
}
std::vector<std::pair<int, int>> ins[N], del[N];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    --x1, --y1, --y2;
    ins[x1].emplace_back(y1, y2);
    del[x2].emplace_back(y1, y2);
  }
  std::multiset<int> obs;
  auto find = [&obs](int x) {
    auto it = obs.upper_bound(x);
    if (it == obs.begin())
      return 0;
    else
      return *(--it) + 1;
  };
  build(1, 0, m);
  set(1, 0, m, 0, 1);
  for (auto &&e : ins[0]) {
    obs.insert(e.first);
    obs.insert(e.second);
  }
  for (int i = 1; i < n; ++i) {
    std::vector<int> add;
    for (auto &&e : ins[i]) {
      int r = e.second + 1;
      int l = find(r);
      add.push_back(l <= r && r < m ? sum(1, 0, m, l, r + 1) : 0);
    }
    std::reverse(add.begin(), add.end());
    for (auto &&e : ins[i]) {
      if (e.second + 1 < m) {
        set(1, 0, m, e.second + 1, add.back());
      }
      add.pop_back();
    }
    for (auto &&e : ins[i]) {
      clear(1, 0, m, e.first, e.second + 1);
      obs.insert(e.first);
      obs.insert(e.second);
    }
    for (auto &&e : del[i]) {
      obs.erase(obs.find(e.first));
      obs.erase(obs.find(e.second));
    }
  }
  int l = find(m - 1);
  printf("%d\n", sum(1, 0, m, l, m));
  return 0;
}