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 p = 1000000007;
const int N = 1000100;
vector<pair<int, int> > in[N], out[N];
multiset<int> block;
int sm[N << 2], n, m, k;
bool zero[N << 2];
inline int stop(int &x) {
  multiset<int>::iterator i;
  i = block.upper_bound(x);
  if (i != block.begin()) {
    --i;
    return *i + 1;
  } else
    return 1;
}
inline void notify(int x) { zero[x] = 1, sm[x] = 0; }
inline void push_up(int x) { sm[x] = (sm[x << 1] + sm[x << 1 | 1]) % p; }
inline void push_down(int x) {
  if (zero[x]) notify(x << 1), notify(x << 1 | 1), zero[x] = 0;
}
void build(int x, int l, int r) {
  if (l == r)
    sm[x] == 0;
  else {
    int mid = (l + r) >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
    push_up(x);
  }
}
void change(int x, int l, int r, int w, int v) {
  if (l == r)
    sm[x] = v;
  else {
    int mid = (l + r) >> 1;
    push_down(x);
    if (w <= mid)
      change(x << 1, l, mid, w, v);
    else
      change(x << 1 | 1, mid + 1, r, w, v);
    push_up(x);
  }
}
void clear(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R)
    notify(x);
  else {
    int mid = (l + r) >> 1;
    push_down(x);
    if (L <= mid) clear(x << 1, l, mid, L, R);
    if (R > mid) clear(x << 1 | 1, mid + 1, r, L, R);
    push_up(x);
  }
}
int query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R)
    return sm[x];
  else {
    int mid = (l + r) >> 1, ans = 0;
    push_down(x);
    if (L <= mid) (ans += query(x << 1, l, mid, L, R)) %= p;
    if (R > mid) (ans += query(x << 1 | 1, mid + 1, r, L, R)) %= p;
    return ans;
  }
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> n >> m >> k;
  int x, y, _x, _y;
  for (int i = 0, nn = int(k); i < nn; ++i) {
    cin >> x >> y >> _x >> _y;
    in[y].push_back(make_pair(x, _x));
    out[_y + 1].push_back(make_pair(x, _x));
  }
  build(1, 1, n);
  change(1, 1, n, 1, 1);
  for (int i = 0, nn = int((int)(in[1]).size()); i < nn; ++i) {
    block.insert(in[1][i].first);
    block.insert(in[1][i].second);
  }
  for (int i = 2, nn = int(m); i <= nn; ++i) {
    vector<int> delta;
    for (int j = 0, nn = int((int)(in[i]).size()); j < nn; ++j) {
      int r = in[i][j].second + 1;
      int l = stop(r);
      if (l <= r && r <= n)
        delta.push_back(query(1, 1, n, l, r));
      else
        delta.push_back(0);
    }
    for (int j = 0, nn = int((int)(in[i]).size()); j < nn; ++j) {
      int r = in[i][j].second + 1;
      if (r <= n) change(1, 1, n, r, delta[j]);
    }
    for (int j = 0, nn = int((int)(in[i]).size()); j < nn; ++j) {
      clear(1, 1, n, in[i][j].first, in[i][j].second);
      block.insert(in[i][j].first);
      block.insert(in[i][j].second);
    }
    for (int j = 0, nn = int((int)(out[i]).size()); j < nn; ++j) {
      block.erase(block.find(out[i][j].first));
      block.erase(block.find(out[i][j].second));
    }
  }
  int l = stop(n);
  int ans = query(1, 1, n, l, n);
  return cout << ans << endl, 0;
}