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;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool f = false;
  for (; !isdigit(c); c = getchar()) f != c == '-';
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  if (f) x = -x;
}
template <typename T, typename... Arg>
inline void read(T &x, Arg &...args) {
  read(x);
  read(args...);
}
template <typename T>
inline void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
struct Seg_Tree {
  struct node {
    int l, r;
    int tag;
    int sum;
  } T[N * 4];
  void build(int x, int l, int r) {
    T[x].l = l, T[x].r = r;
    if (l == r) return;
    int mid = l + r >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
  }
  void pushup(int x) { T[x].sum = (T[x << 1].sum + T[x << 1 | 1].sum) % mod; }
  void pushdown(int x) {
    if (T[x].tag) {
      T[x << 1].tag = T[x << 1 | 1].tag = 1;
      T[x << 1].sum = T[x << 1 | 1].sum = 0;
      T[x].tag = 0;
    }
  }
  void upd(int x, int pos, int val) {
    if (T[x].l == T[x].r) {
      T[x].sum = val;
      return;
    }
    pushdown(x);
    int mid = T[x].l + T[x].r >> 1;
    if (pos <= mid) upd(x << 1, pos, val);
    if (mid < pos) upd(x << 1 | 1, pos, val);
    pushup(x);
  }
  void zero(int x, int l, int r) {
    if (l <= T[x].l && T[x].r <= r) {
      T[x].tag = 1;
      T[x].sum = 0;
      return;
    }
    pushdown(x);
    int mid = T[x].l + T[x].r >> 1;
    if (l <= mid) zero(x << 1, l, r);
    if (mid < r) zero(x << 1 | 1, l, r);
    pushup(x);
  }
  int qry(int x, int l, int r) {
    if (l <= T[x].l && T[x].r <= r) return T[x].sum;
    pushdown(x);
    int tmp = 0, mid = T[x].l + T[x].r >> 1;
    if (l <= mid) (tmp += qry(x << 1, l, r)) %= mod;
    if (mid < r) (tmp += qry(x << 1 | 1, l, r)) %= mod;
    return tmp;
  }
} seg;
int n, m, T;
vector<pair<int, int>> add[1000010], del[1000010];
set<pair<int, int>> s;
signed main() {
  read(n, m, T);
  while (T--) {
    int X1, Y1, X2, Y2;
    read(X1, Y1, X2, Y2);
    add[X1].push_back(make_pair(Y1, Y2));
    del[X2 + 1].push_back(make_pair(Y1, Y2));
  }
  s.insert({0, 0});
  for (auto Seg : add[1]) s.insert(Seg);
  seg.build(1, 1, m);
  seg.upd(1, 1, 1);
  for (int i = 2; i <= n; i++) {
    sort(add[i].begin(), add[i].end());
    reverse(add[i].begin(), add[i].end());
    for (auto Seg : add[i]) {
      int x = Seg.first, y = Seg.second;
      if (y == m) continue;
      auto it = s.lower_bound(make_pair(y + 2, 0));
      it--;
      int ans = 0;
      auto pr = *it;
      if (pr.second <= y) ans = seg.qry(1, pr.second + 1, y + 1);
      seg.upd(1, y + 1, ans);
    }
    for (auto Seg : del[i]) s.erase(Seg);
    for (auto Seg : add[i]) s.insert(Seg), seg.zero(1, Seg.first, Seg.second);
  }
  auto it = s.end();
  it--;
  printf("%d", seg.qry(1, (*it).second + 1, m));
}