#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, oo = inf;
inline long long read() {
  register long long x = 0;
  char f = 0;
  register char c = getchar();
  for (; !isdigit(c); c = getchar()) f |= (c == '-');
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void writeln(long long x, char c, long long y) {
  write(x);
  putchar(c);
  writeln(y);
}
inline void writeln(long long x, char c, long long y, char d, long long z) {
  write(x);
  putchar(c);
  write(y);
  putchar(d);
  writeln(z);
}
const int maxn = 1e5 + 233;
const int mod = 1e9 + 7;
struct wzp {
  int u, l, r, s;
  bool operator<(const wzp &w) const { return u < w.u; }
} a[maxn];
int dp[maxn];
int w, h, n;
stack<int> b[maxn << 2];
void modify(int o, int l, int r, int x, int y, int v) {
  if (l == x && r == y) {
    b[o].push(v);
    return;
  }
  if (y <= ((l + r) >> 1))
    modify((o << 1), l, ((l + r) >> 1), x, y, v);
  else if (((l + r) >> 1) + 1 <= x)
    modify((o << 1 | 1), ((l + r) >> 1) + 1, r, x, y, v);
  else {
    modify((o << 1), l, ((l + r) >> 1), x, ((l + r) >> 1), v);
    modify((o << 1 | 1), ((l + r) >> 1) + 1, r, ((l + r) >> 1) + 1, y, v);
  }
}
void query(int o, int l, int r, int x, int h, int &v) {
  while (!b[o].empty() && a[b[o].top()].u + a[b[o].top()].s < h) b[o].pop();
  if (!b[o].empty() && (v == -1 || (a[b[o].top()].u > a[v].u))) v = b[o].top();
  if (l != r) {
    if (x <= ((l + r) >> 1))
      query((o << 1), l, ((l + r) >> 1), x, h, v);
    else
      query((o << 1 | 1), ((l + r) >> 1) + 1, r, x, h, v);
  }
}
int query(int h, int x) {
  int v = -1;
  query(1, 1, w, x, h, v);
  return v == -1 ? 1 : dp[v];
}
int main() {
  h = read(), w = read(), n = read();
  for (register int i = (1); i <= (n); ++i) {
    a[i].u = read(), a[i].l = read();
    a[i].r = read(), a[i].s = read();
  }
  sort(a + 1, a + 1 + n);
  for (register int i = (1); i <= (n); ++i) {
    if (a[i].l == 1)
      dp[i] = query(a[i].u, a[i].r + 1) * 2 % mod;
    else if (a[i].r == w)
      dp[i] = query(a[i].u, a[i].l - 1) * 2 % mod;
    else
      dp[i] = (query(a[i].u, a[i].l - 1) + query(a[i].u, a[i].r + 1)) % mod;
    modify(1, 1, w, a[i].l, a[i].r, i);
  }
  int ans = 0;
  for (register int i = (1); i <= (w); ++i) ans = (ans + query(h + 1, i)) % mod;
  writeln(ans);
  return 0;
}
