#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const int maxseg = 320;
const int mo = 1000000007;
struct Tbar {
  int h;
  int left, right, endh;
  int lres, rres;
} bar[maxn + 1];
stack<int> seg[maxseg + 1];
stack<int> a[maxn + 1];
int H, W, n;
int result;
bool px(const struct Tbar& a, const struct Tbar& b) { return a.h < b.h; }
void init() {
  int i;
  scanf("%d%d%d", &H, &W, &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d%d%d", &bar[i].h, &bar[i].left, &bar[i].right, &bar[i].endh);
    bar[i].endh += bar[i].h;
  }
  sort(bar + 1, bar + n + 1, px);
}
void ins(int id, int h, int x, int y, int endh) {
  int i, j, q;
  int start, end, startseg, endseg;
  startseg = (x - 1) / maxseg + 1;
  endseg = (y - 1) / maxseg + 1;
  if (startseg == endseg) {
    for (i = x; i <= y; ++i) {
      while (a[i].size() > 0 && bar[a[i].top()].endh <= endh) a[i].pop();
      a[i].push(id);
    }
    return;
  }
  q = startseg * maxseg;
  for (i = x; i <= q; ++i) {
    while (a[i].size() > 0 && bar[a[i].top()].endh <= endh) a[i].pop();
    a[i].push(id);
  }
  for (i = startseg + 1; i < endseg; ++i) {
    while (seg[i].size() > 0 && bar[seg[i].top()].endh <= endh) seg[i].pop();
    seg[i].push(id);
  }
  q = (endseg - 1) * maxseg + 1;
  for (i = q; i <= y; ++i) {
    while (a[i].size() > 0 && bar[a[i].top()].endh <= endh) a[i].pop();
    a[i].push(id);
  }
}
int getGe(int h, int x) {
  int s = (x - 1) / maxseg + 1;
  int res = 0;
  int i;
  while (a[x].size() > 0 && bar[a[x].top()].endh < h) a[x].pop();
  if (a[x].size() > 0) res = a[x].top();
  while (seg[s].size() > 0 && bar[seg[s].top()].endh < h) seg[s].pop();
  if (seg[s].size() > 0) {
    if (res == 0 || seg[s].top() > res) res = seg[s].top();
  }
  if (res == 0)
    return 1;
  else
    return (bar[res].lres + bar[res].rres) % mo;
}
void work() {
  int i, t1, t2;
  for (i = 1; i <= n; ++i) {
    ins(i, bar[i].h, bar[i].left, bar[i].right, bar[i].endh);
    if (bar[i].left - 1 == 0) {
      bar[i].lres = bar[i].rres = getGe(bar[i].h, bar[i].right + 1);
    } else {
      if (bar[i].right + 1 == W + 1) {
        bar[i].lres = bar[i].rres = getGe(bar[i].h, bar[i].left - 1);
      } else {
        bar[i].lres = getGe(bar[i].h, bar[i].left - 1);
        bar[i].rres = getGe(bar[i].h, bar[i].right + 1);
      }
    }
  }
  result = 0;
  for (i = 1; i <= W; ++i) {
    result += getGe(H + 1, i);
    result %= mo;
  }
}
void output() { printf("%d\n", result); }
int main() {
  init();
  work();
  output();
  return 0;
}
