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 Maxn = 1000005, p = 1e9 + 7;
int n, m, k;
set<pair<int, int> > Se;
vector<pair<int, int> > In[Maxn], Out[Maxn];
struct Tree {
  int lt, rt;
  long long sum;
  bool tag;
} tree[4 * Maxn];
void build(int root, int lt, int rt) {
  tree[root] = (Tree){lt, rt, 0, false};
  if (lt + 1 != rt) {
    int mid = (lt + rt) >> 1;
    build(root << 1, lt, mid);
    build(root << 1 | 1, mid, rt);
  }
}
void pushdown(int root) {
  if (tree[root].tag) {
    tree[root << 1].tag = tree[root << 1 | 1].tag = true;
    tree[root << 1].sum = tree[root << 1 | 1].sum = 0;
    tree[root].tag = false;
  }
}
void modify(int root, int pos, long long val) {
  if (tree[root].lt + 1 == tree[root].rt)
    tree[root].sum = val;
  else {
    pushdown(root);
    int mid = (tree[root].lt + tree[root].rt) >> 1;
    if (pos >= mid)
      modify(root << 1 | 1, pos, val);
    else
      modify(root << 1, pos, val);
    tree[root].sum = (tree[root << 1].sum + tree[root << 1 | 1].sum) % p;
  }
}
void clear(int root, int lt, int rt) {
  if (lt == tree[root].lt && rt == tree[root].rt)
    tree[root].sum = 0, tree[root].tag = true;
  else {
    pushdown(root);
    int mid = (tree[root].lt + tree[root].rt) >> 1;
    if (lt >= mid)
      clear(root << 1 | 1, lt, rt);
    else if (rt <= mid)
      clear(root << 1, lt, rt);
    else
      clear(root << 1, lt, mid), clear(root << 1 | 1, mid, rt);
    tree[root].sum = (tree[root << 1].sum + tree[root << 1 | 1].sum) % p;
  }
}
long long ask(int root, int lt, int rt) {
  if (lt >= rt) return 0;
  if (lt == tree[root].lt && rt == tree[root].rt)
    return tree[root].sum;
  else {
    pushdown(root);
    int mid = (tree[root].lt + tree[root].rt) >> 1;
    if (lt >= mid)
      return ask(root << 1 | 1, lt, rt);
    else if (rt <= mid)
      return ask(root << 1, lt, rt);
    else
      return (ask(root << 1, lt, mid) + ask(root << 1 | 1, mid, rt)) % p;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  Se.insert(make_pair(0, 0));
  for (int i = 1; i <= k; i++) {
    int x1, y11, x2, y2;
    scanf("%d%d%d%d", &x1, &y11, &x2, &y2);
    In[x1].push_back(make_pair(y11, y2));
    Out[x2 + 1].push_back(make_pair(y11, y2));
  }
  build(1, 1, m + 1);
  modify(1, 1, 1);
  for (vector<pair<int, int> >::iterator it = In[1].begin(); it != In[1].end();
       it++)
    Se.insert(*it);
  for (int i = 2; i <= n; i++) {
    sort(In[i].begin(), In[i].end());
    reverse(In[i].begin(), In[i].end());
    for (vector<pair<int, int> >::iterator it = In[i].begin();
         it != In[i].end(); it++) {
      if (it->second == m) continue;
      modify(1, it->second + 1,
             ask(1,
                 (--Se.lower_bound(make_pair(it->second + 1, 0x3f3f3f3f)))
                         ->second +
                     1,
                 it->second + 2));
    }
    for (vector<pair<int, int> >::iterator it = Out[i].begin();
         it != Out[i].end(); it++)
      Se.erase(Se.find(*it));
    for (vector<pair<int, int> >::iterator it = In[i].begin();
         it != In[i].end(); it++) {
      Se.insert(*it);
      clear(1, it->first, it->second + 1);
    }
  }
  if (Se.rbegin()->second == m)
    puts("0");
  else
    printf("%lld\n", ask(1, Se.rbegin()->second + 1, m + 1));
  return 0;
}