#include <bits/stdc++.h>
using namespace std;
int n, m, k;
long long mod = 1e9 + 7;
struct ZA {
  int shang, xia, ks, js;
} za[100010];
struct TREE {
  long long zh, bj;
} tr[5000010], tr1[5000010];
bool gz(ZA x, ZA y) {
  if (x.ks == y.ks) {
    return x.shang > y.shang;
  }
  return x.ks < y.ks;
}
void bjxc1(int p, int ls, int rs) {
  if (tr1[p].bj == 0) return;
  tr1[p].bj = 0;
  tr1[ls].zh = 0;
  tr1[ls].bj = 1;
  tr1[rs].zh = 0;
  tr1[rs].bj = 1;
}
void xg1(int l, int r, int p, int wz, long long val) {
  if (l == r && l == wz) {
    tr1[p].zh += val;
    if (tr1[p].zh >= mod) tr1[p].zh -= mod;
    return;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc1(p, ls, rs);
  if (wz <= mid)
    xg1(l, mid, ls, wz, val);
  else
    xg1(mid + 1, r, rs, wz, val);
  tr1[p].zh = tr1[ls].zh + tr1[rs].zh;
  if (tr1[p].zh >= mod) tr1[p].zh -= mod;
  return;
}
void xgg1(int l, int r, int p, int ll, int rr) {
  if (ll <= l && r <= rr) {
    tr1[p].bj = 1;
    tr1[p].zh = 0;
    return;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc1(p, ls, rs);
  if (ll <= mid) xgg1(l, mid, ls, ll, rr);
  if (rr > mid) xgg1(mid + 1, r, rs, ll, rr);
  tr1[p].zh = tr1[ls].zh + tr1[rs].zh;
  if (tr1[p].zh >= mod) tr1[p].zh -= mod;
  return;
}
long long cx1(int l, int r, int p, int ll, int rr) {
  if (ll <= l && r <= rr) {
    return tr1[p].zh;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  long long jgg = 0;
  bjxc1(p, ls, rs);
  if (ll <= mid) {
    jgg += cx1(l, mid, ls, ll, rr);
    if (jgg >= mod) jgg -= mod;
  }
  if (rr > mid) {
    jgg += cx1(mid + 1, r, rs, ll, rr);
    if (jgg >= mod) jgg -= mod;
  }
  return jgg;
}
void bjxc(int p, int ls, int rs, int l, int r, int mid) {
  tr[ls].bj += tr[p].bj;
  tr[ls].zh += tr[p].bj * (mid - l + 1);
  tr[rs].bj += tr[p].bj;
  tr[rs].zh += tr[p].bj * (r - mid);
  tr[p].bj = 0;
  return;
}
void xg(int l, int r, int p, int ll, int rr, long long val) {
  if (ll <= l && r <= rr) {
    tr[p].bj += val;
    tr[p].zh += (r - l + 1) * val;
    return;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc(p, ls, rs, l, r, mid);
  if (ll <= mid) xg(l, mid, ls, ll, rr, val);
  if (rr > mid) xg(mid + 1, r, rs, ll, rr, val);
  tr[p].zh = tr[ls].zh + tr[rs].zh;
  return;
}
long long cx(int l, int r, int p, int ll, int rr) {
  if (ll <= l && r <= rr) {
    return tr[p].zh;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  long long jgg = 0;
  bjxc(p, ls, rs, l, r, mid);
  if (ll <= mid) jgg += cx(l, mid, ls, ll, rr);
  if (rr > mid) jgg += cx(mid + 1, r, rs, ll, rr);
  return jgg;
}
int cxqq(int l, int r, int p, long long nw, long long val) {
  if (l == r) {
    return l;
  }
  int mid = (l + r) >> 1, ls = p << 1, rs = (p << 1) + 1;
  bjxc(p, ls, rs, l, r, mid);
  if (nw + tr[ls].zh >= val) {
    return cxqq(l, mid, ls, nw, val);
  } else {
    return cxqq(mid + 1, r, rs, nw + tr[ls].zh, val);
  }
}
priority_queue<pair<int, int> > q;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d%d", &za[i].ks, &za[i].xia, &za[i].js, &za[i].shang);
    za[i].ks += 2;
    za[i].js += 2;
  }
  k += 2;
  n += 3;
  za[k].ks = za[k].js = n;
  za[k].xia = 1;
  za[k].shang = m - 1;
  za[k - 1].ks = za[k - 1].js = 2;
  za[k - 1].xia = 2;
  za[k - 1].shang = m;
  sort(za + 1, za + k + 1, gz);
  xg1(1, m, 1, 1, 1);
  for (int i = 1; i <= k; i++) {
    while (!q.empty()) {
      int id = q.top().second;
      if (-q.top().first < za[i].ks - 1) {
        xg(1, m, 1, za[id].xia, za[id].shang, -1);
        q.pop();
      } else {
        break;
      }
    }
    long long emm, qq;
    if (za[i].shang != m) {
      emm = cx(1, m, 1, 1, za[i].shang + 1);
      qq = cxqq(1, m, 1, 0, emm);
      if (emm == 0) qq = 0;
    }
    if (za[i].shang != m && qq < za[i].shang) {
      long long qw = cx1(1, m, 1, qq + 1, za[i].shang);
      xg1(1, m, 1, za[i].shang + 1, qw);
    }
    xg(1, m, 1, za[i].xia, za[i].shang, 1);
    xgg1(1, m, 1, za[i].xia, za[i].shang);
    q.push(make_pair(-za[i].js, i));
  }
  printf("%lld", tr1[1].zh);
  return 0;
}
