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>
#pragma warning(disable : 4996)
using namespace std;
int n, m, p;
struct NODE {
  long long lazy;
  long long sum;
  NODE() : lazy(-1) {}
} it[3000000];
long long len[3000000];
int S;
vector<pair<int, int> > in[3000000];
vector<pair<int, int> > out[3000000];
set<pair<int, int> > s;
void recalc(int now) {
  if (it[now].lazy >= 0)
    it[now].sum = it[now].lazy * len[now] % 1000000007;
  else
    it[now].sum = (it[now * 2].sum + it[now * 2 + 1].sum) % 1000000007;
}
void pushdown(int now) {
  if (it[now].lazy >= 0)
    it[now * 2].lazy = it[now].lazy, it[now * 2 + 1].lazy = it[now].lazy,
             it[now].lazy = -1;
  recalc(now * 2), recalc(now * 2 + 1);
}
void update(int now, int x, int y, int s, int e, long long v) {
  if (x > y) return;
  if (x == s && y == e) {
    it[now].lazy = v;
    recalc(now);
    return;
  }
  pushdown(now);
  update(now * 2, x, min(y, (s + e) / 2), s, (s + e) / 2, v);
  update(now * 2 + 1, max(x, (s + e) / 2 + 1), y, (s + e) / 2 + 1, e, v);
  recalc(now);
}
long long getsum(int now, int x, int y, int s, int e) {
  if (x > y) return 0;
  if (x == s && y == e) return it[now].sum;
  pushdown(now);
  return (getsum(now * 2, x, min(y, (s + e) / 2), s, (s + e) / 2) +
          getsum(now * 2 + 1, max(x, (s + e) / 2 + 1), y, (s + e) / 2 + 1, e)) %
         1000000007;
}
int main() {
  int i, j, k, l;
  cin >> n >> m >> p;
  for (i = 0; i < p; i++) {
    int x, y, z, w;
    scanf("%d%d%d%d", &x, &y, &z, &w);
    in[y].emplace_back(x, z);
    out[w + 1].emplace_back(x, z);
  }
  for (S = 1; S <= n + 2; S *= 2)
    ;
  for (i = S; i < S * 2; i++) len[i] = 1, it[i].lazy = 0;
  for (i = S - 1; i > 0; i--) len[i] = len[i * 2] + len[i * 2 + 1];
  update(1, 1, 1, 0, S - 1, 1);
  for (auto e : in[1]) s.insert(e);
  for (i = 1; i <= m; i++) {
    sort((in[i]).begin(), (in[i]).end());
    reverse((in[i]).begin(), (in[i]).end());
    for (auto e : in[i]) {
      auto ix = s.lower_bound(make_pair(e.second + 2, -0x3f3f3f3f));
      int tar = 1;
      if (ix != s.begin()) tar = prev(ix)->second + 1;
      long long res = getsum(1, tar, e.second + 1, 0, S - 1);
      update(1, e.second + 1, e.second + 1, 0, S - 1, res);
    }
    for (auto e : out[i]) s.erase(e);
    for (auto e : in[i]) update(1, e.first, e.second, 0, S - 1, 0), s.insert(e);
  }
  cout << getsum(1, s.size() ? prev(s.end())->second + 1 : 1, n, 0, S - 1);
  return 0;
}