#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int h, w, n;
struct Data {
  int u, l, r, s;
  bool operator<(const Data &a) const { return u > a.u; }
} a[maxn];
vector<pair<int, int> > qwq[maxn << 2];
int Min[maxn << 2];
void pushup(int rt) { Min[rt] = min(Min[rt << 1], Min[rt << 1 | 1]); }
void update(int rt, int l, int r, int p, int x, int k) {
  if (l == r) {
    qwq[rt].push_back(make_pair(x, k));
    Min[rt] = x;
    return;
  }
  int mid = l + r >> 1;
  if (p <= mid)
    update(rt << 1, l, mid, p, x, k);
  else
    update(rt << 1 | 1, mid + 1, r, p, x, k);
  pushup(rt);
}
int tmp;
void Mod(int &x, int k) {
  x += k;
  if (x >= 1000000007) x -= 1000000007;
}
void query(int rt, int l, int r, int L, int R, int p) {
  if (l == r) {
    int siz = qwq[rt].size();
    while (siz && qwq[rt][siz - 1].first <= p) {
      Mod(tmp, qwq[rt][siz - 1].second);
      qwq[rt].pop_back(), siz = qwq[rt].size();
      if (siz)
        Min[rt] = qwq[rt][siz - 1].first;
      else
        Min[rt] = 0x3f3f3f3f;
    }
    return;
  }
  int mid = l + r >> 1;
  if (L <= mid && Min[rt << 1] <= p) query(rt << 1, l, mid, L, R, p);
  if (R > mid && Min[rt << 1 | 1] <= p) query(rt << 1 | 1, mid + 1, r, L, R, p);
  pushup(rt);
}
int main() {
  scanf("%d%d%d", &h, &w, &n);
  memset(Min, 0x3f, sizeof(Min));
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d%d", &a[i].u, &a[i].l, &a[i].r, &a[i].s);
    a[i].s = min(a[i].s + a[i].u, h + 1);
  }
  for (int i = 1; i <= w; ++i) update(1, 1, w, i, h + 1, 1);
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i) {
    tmp = 0, query(1, 1, w, a[i].l, a[i].r, a[i].s);
    if (a[i].l == 1 && a[i].r == w) continue;
    if (a[i].l == 1)
      update(1, 1, w, a[i].r + 1, a[i].u, tmp * 2 % 1000000007);
    else if (a[i].r == w)
      update(1, 1, w, a[i].l - 1, a[i].u, tmp * 2 % 1000000007);
    else {
      update(1, 1, w, a[i].l - 1, a[i].u, tmp);
      update(1, 1, w, a[i].r + 1, a[i].u, tmp);
    }
  }
  tmp = 0, query(1, 1, w, 1, w, h + 1);
  printf("%d\n", tmp);
  return 0;
}
