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>
const int MOD = 1000000007;
struct SumTree {
  int BOTTOM;
  std::vector<int> t, u;
  void go(int v) {
    if (v >= BOTTOM) return;
    go(v << 1);
    go((v << 1) + 1);
    t[v] = (t[v << 1] + t[(v << 1) + 1]) % MOD;
  }
  void build(std::vector<int> arr) {
    BOTTOM = 1;
    while (BOTTOM < (int)(arr).size()) BOTTOM *= 2;
    t.resize(BOTTOM * 2);
    u.resize(BOTTOM * 2, -1);
    for (int i = 0; i < ((int)(arr).size()); ++i) t[BOTTOM + i] = arr[i];
    for (int i = ((int)(arr).size()); i < (BOTTOM); ++i) t[BOTTOM + i] = 0;
    go(1);
  }
  void upd(int v, int lo, int hi) {
    if (u[v] != -1) {
      t[v] = (1ll * (hi - lo + 1) * u[v]) % MOD;
      if (v < BOTTOM) u[v << 1] = u[(v << 1) + 1] = u[v];
      u[v] = -1;
    }
  }
  void add(int a, int val, int v = 1, int lo = 0, int hi = -2) {
    if (hi == -2) hi = BOTTOM - 1;
    upd(v, lo, hi);
    if (lo == hi) {
      t[v] = (t[v] + val) % MOD;
      return;
    }
    int mid = (lo + hi) / 2;
    if (a > mid)
      add(a, val, (v << 1) + 1, mid + 1, hi);
    else
      add(a, val, (v << 1), lo, mid);
    upd(v << 1, lo, mid);
    upd((v << 1) + 1, mid + 1, hi);
    t[v] = (t[v << 1] + t[(v << 1) + 1]) % MOD;
  }
  void set(int a, int b, int val, int v = 1, int lo = 0, int hi = -2) {
    if (hi == -2) hi = BOTTOM - 1;
    upd(v, lo, hi);
    if (a > b) return;
    if (a == lo && b == hi) {
      u[v] = val;
      upd(v, lo, hi);
      return;
    }
    int mid = (lo + hi) / 2;
    set(a, std::min(mid, b), val, v << 1, lo, mid);
    set(std::max(a, mid + 1), b, val, (v << 1) + 1, mid + 1, hi);
    t[v] = (t[v << 1] + t[(v << 1) + 1]) % MOD;
  }
  int query(int a, int b, int v = 1, int lo = 0, int hi = -2) {
    if (hi == -2) hi = BOTTOM - 1;
    upd(v, lo, hi);
    if (a > b) return 0;
    if (a == lo && b == hi) return t[v];
    int mid = (lo + hi) / 2;
    return (query(a, std::min(b, mid), v << 1, lo, mid) +
            query(std::max(a, mid + 1), b, (v << 1) + 1, mid + 1, hi)) %
           MOD;
  }
};
struct Event {
  int x;
  int s, e;
  int type;
  Event() {}
  Event(int _x, int _s, int _e, int _type) : x(_x), s(_s), e(_e), type(_type) {}
};
SumTree tree;
int n, m, k;
std::vector<Event> events;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> n >> m >> k;
  if (k == 0) {
    std::cout << 1 << "\n";
    return 0;
  }
  for (int i = 0; i < (k); ++i) {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    events.push_back(Event(a, b, d, 1));
    events.push_back(Event(c + 1, b, d, -1));
  }
  tree.build(std::vector<int>(m + 5));
  tree.add(0, 1);
  std::sort(events.begin(), events.end(), [](const Event &a, const Event &b) {
    if (a.x == b.x) {
      if (a.type == b.type) {
        return a.s > b.s;
      }
      return a.type == 1;
    }
    return a.x < b.x;
  });
  std::multiset<std::pair<int, int> > obs;
  auto it = events.begin();
  while (it != events.end() && it->x < n) {
    if (it->type == 1) {
      auto xd = obs.lower_bound(std::make_pair(it->e + 2, -1));
      int lef = 0;
      int rig = it->e;
      if (xd != obs.begin()) lef = (--xd)->second + 1;
      if (it->x > 0 && lef <= rig && it->e + 1 < m) {
        int dd = tree.query(lef, rig);
        tree.add(it->e + 1, dd);
      }
      obs.insert(std::make_pair(it->s, it->e));
      tree.set(it->s, it->e, 0);
    } else {
      obs.erase(obs.find(std::make_pair(it->s, it->e)));
    }
    it++;
  }
  auto xd = obs.end();
  if (xd != obs.begin()) xd--;
  int lef = 0;
  int rig = m - 1;
  if (xd != obs.end()) lef = xd->second;
  std::cout << tree.query(lef, rig) << "\n";
  return 0;
}