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;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 1000005;
const int MAXT = 2100000;
const int mod = 1e9 + 7;
struct seg {
  int tree[MAXT];
  int lazy[MAXT];
  void lazydown(int p) {
    if (lazy[p]) {
      lazy[2 * p] = lazy[2 * p + 1] = 1;
      tree[2 * p] = tree[2 * p + 1] = 0;
      lazy[p] = 0;
    }
  }
  void add(int pos, int s, int e, int p, int v) {
    if (s == e) {
      tree[p] += v;
      tree[p] %= mod;
      return;
    }
    lazydown(p);
    int m = (s + e) / 2;
    if (pos <= m)
      add(pos, s, m, 2 * p, v);
    else
      add(pos, m + 1, e, 2 * p + 1, v);
    tree[p] = (tree[2 * p] + tree[2 * p + 1]) % mod;
  }
  void zero(int s, int e, int ps, int pe, int p) {
    if (e < ps || pe < s) return;
    if (s <= ps && pe <= e) {
      tree[p] = 0;
      lazy[p] = 1;
      return;
    }
    int pm = (ps + pe) / 2;
    lazydown(p);
    zero(s, e, ps, pm, 2 * p);
    zero(s, e, pm + 1, pe, 2 * p + 1);
    tree[p] = (tree[2 * p] + tree[2 * p + 1]) % mod;
  }
  int sum(int s, int e, int ps, int pe, int p) {
    if (e < ps || pe < s) return 0;
    if (s <= ps && pe <= e) return tree[p];
    int pm = (ps + pe) / 2;
    lazydown(p);
    return (sum(s, e, ps, pm, 2 * p) + sum(s, e, pm + 1, pe, 2 * p + 1)) % mod;
  }
} seg;
int n, w, h;
vector<pi> add[MAXN], rem[MAXN];
int dp[MAXN];
void upd(int x, int v) { seg.add(x, 1, h, 1, v); }
void zero(int s, int e) { seg.zero(s, e, 1, h, 1); }
int sum(int s, int e) { return seg.sum(s, e, 1, h, 1); }
int main() {
  scanf("%d %d %d", &w, &h, &n);
  for (int i = 0; i < n; i++) {
    int sx, sy, ex, ey;
    scanf("%d %d %d %d", &sx, &sy, &ex, &ey);
    add[sx].push_back(pi(sy, ey));
    rem[ex + 1].push_back(pi(sy, ey));
  }
  upd(1, 1);
  set<pi> s;
  for (auto &i : add[1]) s.insert(i);
  for (int i = 2; i <= w; i++) {
    vector<pi> v;
    for (auto &j : add[i]) {
      if (j.second == h) continue;
      int pos = j.second + 1;
      auto l = s.upper_bound(pi(pos, 1e9));
      int stp = 1;
      if (l != s.begin()) stp = prev(l)->second + 1;
      if (stp < pos) v.push_back(pi(pos, sum(stp, pos - 1)));
    }
    for (auto &j : add[i]) {
      zero(j.first, j.second);
    }
    for (auto &j : rem[i]) s.erase(j);
    for (auto &j : add[i]) s.insert(j);
    for (auto &j : v) {
      if (j.first > h) continue;
      auto l = s.upper_bound(pi(j.first, 1e9));
      if (l != s.begin() && prev(l)->second >= j.first) {
        continue;
      }
      upd(j.first, j.second);
    }
  }
  auto l = (s.size() ? (s.rbegin()->second) : 0) + 1;
  cout << sum(l, h) << endl;
}