#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20, mod = 1e9 + 7;
template <typename T>
void rd(T &x) {
  int ch = getchar();
  x = 0;
  bool f = false;
  for (; ch < '0' || ch > '9'; ch = getchar()) f |= ch == '-';
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
void qmo(int &x) { x += x >> 31 & mod; }
int n, m, k, seg[N << 1];
vector<pair<int, int> > add[N], del[N];
set<pair<int, int> > st;
void upd(int p, int v) {
  v -= mod;
  p += N;
  while (p) {
    qmo(seg[p] += v);
    p >>= 1;
  }
}
void reset(int l, int r, int x = 1, int L = 0, int R = N - 1) {
  if (!seg[x]) return;
  if (l <= L && R <= r) seg[x] = 0;
  if (L == R) return;
  int md = L + R >> 1;
  if (l <= md) reset(l, r, x << 1, L, md);
  if (md < r) reset(l, r, x << 1 | 1, md + 1, R);
  qmo(seg[x] = seg[x << 1] + seg[x << 1 | 1] - mod);
}
int qry(int l, int r) {
  int res = 0;
  l += N;
  r += N;
  while (l <= r) {
    if (l & 1) qmo(res += seg[l++] - mod);
    if (!(r & 1)) qmo(res += seg[r--] - mod);
    l >>= 1;
    r >>= 1;
  }
  return res;
}
int main() {
  rd(n);
  rd(m);
  rd(k);
  for (int i = 0, x1, y1, x2, y2; i < k; ++i) {
    rd(x1);
    rd(y1);
    rd(x2);
    rd(y2);
    add[x1 - 1].emplace_back(y1, y2);
    del[x2].emplace_back(y1, y2);
  }
  add[n].emplace_back(1, m - 1);
  for (int i = 0; i <= n; ++i) {
    if (i == 1) upd(1, 1);
    sort(add[i].begin(), add[i].end(), greater<pair<int, int> >());
    for (int j = 0; j < add[i].size(); ++j) {
      if (!j || add[i][j - 1].first > add[i][j].second + 1) {
        auto it = st.lower_bound(make_pair(add[i][j].second + 2, 0));
        upd(add[i][j].second + 1,
            qry(it == st.begin() ? 1 : 1 + (--it)->second, add[i][j].second));
      }
      reset(add[i][j].first, add[i][j].second);
    }
    for (pair<int, int> _ : del[i]) st.erase(_);
    for (pair<int, int> _ : add[i]) st.insert(_);
  }
  printf("%d\n", qry(1, m));
}
