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, maxk = 100010, maxn = 1000010;
int n, m, k, tot;
struct node {
  int x, l, r, k;
} p[maxk * 3];
int s[maxn << 2], tag[maxn << 2], siz[maxn << 2];
bool cmp(const node &a, const node &b) {
  return (a.x == b.x) ? ((a.k == b.k) ? (a.l > b.l) : (a.k < b.k))
                      : (a.x < b.x);
}
inline void pushdown(int l, int r, int x) {
  if (tag[x] == 1) {
    s[x << 1] = s[x << 1 | 1] = 0, tag[x << 1] = tag[x << 1 | 1] = 1;
    int mid = (l + r) >> 1;
    siz[x << 1] = mid - l + 1, siz[x << 1 | 1] = r - mid, tag[x] = 0;
  }
  if (tag[x] == 2)
    s[x << 1] = s[x << 1 | 1] = 0, tag[x << 1] = tag[x << 1 | 1] = 2,
           siz[x << 1] = siz[x << 1 | 1] = 0, tag[x] = 0;
}
inline void pushup(int x) {
  s[x] = s[x << 1] + s[x << 1 | 1], siz[x] = siz[x << 1] + siz[x << 1 | 1];
  if (s[x] >= P) s[x] -= P;
}
void modify(int l, int r, int x, int a, int b) {
  if (l == r) {
    s[x] = b;
    return;
  }
  pushdown(l, r, x);
  int mid = (l + r) >> 1;
  if (a <= mid)
    modify(l, mid, x << 1, a, b);
  else
    modify(mid + 1, r, x << 1 | 1, a, b);
  pushup(x);
}
void updata(int l, int r, int x, int a, int b, int c) {
  if (a <= l && r <= b) {
    if (c == 1)
      tag[x] = 1, siz[x] = r - l + 1, s[x] = 0;
    else
      tag[x] = 2, siz[x] = s[x] = 0;
    return;
  }
  pushdown(l, r, x);
  int mid = (l + r) >> 1;
  if (a <= mid) updata(l, mid, x << 1, a, b, c);
  if (b > mid) updata(mid + 1, r, x << 1 | 1, a, b, c);
  pushup(x);
}
int query(int l, int r, int x, int a, int b) {
  if (a <= l && r <= b) return s[x];
  pushdown(l, r, x);
  int mid = (l + r) >> 1, ret = 0;
  if (a <= mid) ret += query(l, mid, x << 1, a, b);
  if (b > mid) ret += query(mid + 1, r, x << 1 | 1, a, b);
  if (ret >= P) ret -= P;
  return ret;
}
int count(int l, int r, int x, int a, int b) {
  if (a <= l && r <= b) return siz[x];
  pushdown(l, r, x);
  int mid = (l + r) >> 1;
  if (b <= mid) return count(l, mid, x << 1, a, b);
  if (a > mid) return count(mid + 1, r, x << 1 | 1, a, b);
  return count(l, mid, x << 1, a, b) + count(mid + 1, r, x << 1 | 1, a, b);
}
int find(int l, int r, int x, int a) {
  if (l == r) return l;
  pushdown(l, r, x);
  int mid = (l + r) >> 1;
  if (a <= siz[x << 1]) return find(l, mid, x << 1, a);
  return find(mid + 1, r, x << 1 | 1, a - siz[x << 1]);
}
inline int rd() {
  int ret = 0, f = 1;
  char gc = getchar();
  while (gc < '0' || gc > '9') {
    if (gc == '-') f = -f;
    gc = getchar();
  }
  while (gc >= '0' && gc <= '9') ret = ret * 10 + (gc ^ '0'), gc = getchar();
  return ret * f;
}
int main() {
  n = rd(), m = rd(), k = rd();
  int i, a, b, c, d;
  for (i = 1; i <= k; i++) {
    a = rd(), b = rd(), c = rd(), d = rd();
    p[++tot].x = a, p[tot].l = b, p[tot].r = d, p[tot].k = 2;
    p[++tot].x = a + 1, p[tot].l = b, p[tot].r = d, p[tot].k = 1;
    p[++tot].x = c + 1, p[tot].l = b, p[tot].r = d, p[tot].k = 3;
  }
  p[++tot].x = 1, p[tot].l = 2, p[tot].r = m, p[tot].k = 1;
  p[++tot].x = 1, p[tot].l = 2, p[tot].r = m, p[tot].k = 3;
  p[++tot].x = n + 1, p[tot].l = 1, p[tot].r = m - 1, p[tot].k = 2;
  sort(p + 1, p + tot + 1, cmp);
  modify(1, m, 1, 1, 1);
  for (a = 1; a <= tot; a = b + 1) {
    for (b = a; b < tot && p[b + 1].x == p[b].x && p[b + 1].k == p[b].k; b++)
      ;
    if (p[a].k == 2) {
      for (i = a; i <= b; i++)
        if (p[i].r != m) {
          c = count(1, m, 1, 1, p[i].r + 1);
          if (!c)
            d = 0;
          else
            d = find(1, m, 1, c);
          if (d != p[i].r + 1)
            modify(1, m, 1, p[i].r + 1, query(1, m, 1, d + 1, p[i].r + 1));
        }
    } else if (p[a].k == 1)
      for (i = a; i <= b; i++) updata(1, m, 1, p[i].l, p[i].r, 1);
    else
      for (i = a; i <= b; i++) updata(1, m, 1, p[i].l, p[i].r, 2);
  }
  printf("%d", query(1, m, 1, m, m));
  return 0;
}