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;
int n, m;
const int mod = 1000000000 + 7;
int prop[1000010 * 4];
long long add[1000010 * 4];
vector<pair<int, int> > start[1000010], fin[1000010];
void pushdown(int c) {
  int l = c << 1;
  int r = l + 1;
  if (prop[c] != -1) {
    prop[l] = prop[r] = prop[c];
    add[l] = add[r] = 0;
    prop[c] = -1;
  } else {
    if (prop[l] == -1) {
      add[l] += add[c];
      add[l] %= mod;
    } else {
      prop[l] += add[c];
      prop[l] %= mod;
    }
    if (prop[r] == -1) {
      add[r] += add[c];
      add[r] %= mod;
    } else {
      prop[r] += add[c];
      prop[r] %= mod;
    }
    add[c] = 0;
  }
}
void update(int x, int y, int val, int c = 1, int b = 0, int e = m) {
  if (x > y) return;
  if (x <= b && e <= y) {
    if (prop[c] != -1)
      prop[c] = (prop[c] + val) % mod;
    else
      add[c] = (add[c] + val) % mod;
    return;
  }
  if (y < b || e < x) return;
  pushdown(c);
  int m = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  update(x, y, val, l, b, m);
  update(x, y, val, r, m + 1, e);
}
void makezero(int x, int y, int c = 1, int b = 0, int e = m) {
  if (x <= b && e <= y) {
    prop[c] = 0;
    add[c] = 0;
    return;
  }
  if (y < b || e < x) return;
  pushdown(c);
  int m = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  makezero(x, y, l, b, m);
  makezero(x, y, r, m + 1, e);
}
int getValue(int x, int c = 1, int b = 0, int e = m) {
  if (b == e) {
    return prop[c];
  }
  pushdown(c);
  int m = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  if (x <= m)
    return getValue(x, l, b, m);
  else
    return getValue(x, r, m + 1, e);
}
int t[1000010 * 4];
int p[1000010 * 4];
void create(int c = 1, int b = 0, int e = m) {
  t[c] = m + 1;
  p[c] = -1;
  if (b == e) return;
  int mid = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  create(l, b, mid);
  create(r, mid + 1, e);
}
void propagate(int c, int b, int e) {
  if (p[c] == -1) return;
  int l = c << 1;
  int r = l + 1;
  int mid = (b + e) >> 1;
  if (p[c] == 0) {
    p[l] = p[r] = 0;
    t[l] = m + 1;
    t[r] = m + 1;
  } else {
    p[l] = p[r] = 1;
    t[l] = b;
    t[r] = mid + 1;
  }
  p[c] = -1;
}
void addrange(int x, int y, int c = 1, int b = 0, int e = m) {
  if (x <= b && e <= y) {
    p[c] = 1;
    t[c] = b;
    return;
  }
  if (y < b || e < x) return;
  propagate(c, b, e);
  int mid = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  addrange(x, y, l, b, mid);
  addrange(x, y, r, mid + 1, e);
  t[c] = min(t[l], t[r]);
}
void delrange(int x, int y, int c = 1, int b = 0, int e = m) {
  if (x <= b && e <= y) {
    p[c] = 0;
    t[c] = m + 1;
    return;
  }
  if (y < b || e < x) return;
  propagate(c, b, e);
  int mid = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  delrange(x, y, l, b, mid);
  delrange(x, y, r, mid + 1, e);
  t[c] = min(t[l], t[r]);
}
int query(int x, int c = 1, int b = 0, int e = m) {
  if (b == e) return t[c];
  propagate(c, b, e);
  int mid = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  if (x <= mid)
    return min(t[r], query(x, l, b, mid));
  else
    return query(x, r, mid + 1, e);
}
void output() {
  for (int i = 1; i <= m; i++) {
    cout << getValue(i) << " ";
  }
  cout << endl;
}
int main(int argc, char const *argv[]) {
  int k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    update(i, i, 1);
  }
  for (int i = 1; i <= k; i++) {
    int x1, y1;
    int x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    start[x1].push_back(pair<int, int>(y1, y2));
    fin[x2].push_back(pair<int, int>(y1, y2));
  }
  for (int i = 1; i <= n; i++) {
    sort(start[i].begin(), start[i].end());
    sort(fin[i].begin(), fin[i].end());
  }
  if (!start[1].empty()) {
    makezero(start[1][0].first, m);
  }
  create();
  for (int i = 1; i <= n; i++) {
    for (auto j : fin[i - 1]) {
      delrange(j.first, j.second);
    }
    for (auto j : start[i]) {
      addrange(j.first, j.second);
    }
    for (auto j : start[i]) {
      makezero(j.first, j.second);
    }
    int sz = fin[i - 1].size();
    for (int j = sz - 1; j >= 0; j--) {
      int nxt = query(fin[i - 1][j].first) - 1;
      update(fin[i - 1][j].first, nxt, getValue(fin[i - 1][j].first - 1));
    }
  }
  printf("%d\n", getValue(m));
  return 0;
}