#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100000;
const int maxk = 110000;
const long long Mod = 1e9 + 7;
int n, m, k;
struct segment {
  long long c, flag;
} seg[maxn << 2];
void pushdown(const int x, const int l, const int r) {
  if (seg[x].flag != -1) {
    int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
    long long fl = seg[x].flag % Mod;
    seg[x].flag = -1;
    seg[lc].c = (long long)(mid - l + 1) * fl % Mod;
    seg[lc].flag = fl;
    seg[rc].c = (long long)(r - mid) * fl % Mod;
    seg[rc].flag = fl;
  }
}
void pushup(const int x) {
  int lc = x << 1, rc = lc | 1;
  seg[x].c = (seg[lc].c + seg[rc].c) % Mod;
}
int lx, rx;
long long v;
void upd(const int x, const int l, const int r) {
  if (rx < l || r < lx) return;
  if (lx <= l && r <= rx) {
    seg[x].c = (long long)(r - l + 1) * v % Mod;
    seg[x].flag = v;
    return;
  }
  pushdown(x, l, r);
  int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
  upd(lc, l, mid);
  upd(rc, mid + 1, r);
  pushup(x);
}
void add(const int x, const int l, const int r) {
  if (l == r) {
    seg[x].c += v;
    return;
  }
  int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
  pushdown(x, l, r);
  if (lx <= mid)
    add(lc, l, mid);
  else
    add(rc, mid + 1, r);
  pushup(x);
}
void cal(const int x, const int l, const int r) {
  if (rx < l || r < lx) return;
  if (lx <= l && r <= rx) {
    v += seg[x].c;
    return;
  }
  int mid = l + r >> 1, lc = x << 1, rc = lc | 1;
  pushdown(x, l, r);
  cal(lc, l, mid);
  cal(rc, mid + 1, r);
}
struct D {
  int pos, x1, x2, i;
  D() {}
  D(const int _pos, const int _x1, const int _x2, const int _i) {
    pos = _pos;
    x1 = _x1;
    x2 = _x2;
    i = _i;
  }
} a[maxk << 1];
int cnt;
inline bool cmp(const D x, const D y) {
  if (x.pos == y.pos) return x.i == y.i ? x.x1 > y.x1 : x.i > y.i;
  return x.pos < y.pos;
}
multiset<int> S;
multiset<int>::iterator it;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    a[++cnt] = D(x1, y1, y2, 1);
    a[++cnt] = D(x2 + 1, y1, y2, -1);
  }
  sort(a + 1, a + cnt + 1, cmp);
  lx = rx = 1;
  v = 1ll;
  upd(1, 1, m);
  int pos = 1;
  S.insert(0);
  S.insert(m + 1);
  while (pos <= cnt && a[pos].pos == 1) {
    S.insert(a[pos].x1);
    S.insert(a[pos].x2);
    pos++;
  }
  for (int i = 2; i <= n; i++) {
    while (pos <= cnt && a[pos].pos == i) {
      if (a[pos].i == 1) {
        it = S.upper_bound(a[pos].x2);
        it--;
        lx = (*it) + 1, rx = a[pos].x2;
        v = 0ll;
        if (lx <= rx) cal(1, 1, m);
        v %= Mod;
        it = S.upper_bound(a[pos].x2);
        if ((*it) != a[pos].x2 + 1) lx = rx = a[pos].x2 + 1, add(1, 1, m);
        lx = a[pos].x1, rx = a[pos].x2, v = 0ll, upd(1, 1, m);
        S.insert(a[pos].x1);
        S.insert(a[pos].x2);
      } else {
        it = S.find(a[pos].x1);
        S.erase(it);
        it = S.find(a[pos].x2);
        S.erase(it);
      }
      pos++;
    }
  }
  it = S.lower_bound(m);
  it--;
  lx = (*it) + 1, rx = m, v = 0;
  if (lx <= rx) cal(1, 1, m);
  printf("%I64d\n", v % Mod);
  return 0;
}
