#include <bits/stdc++.h>
using namespace std;
struct xy {
  long long h, l, r, s;
} e[100005];
struct p {
  long long id, h, opt;
} b[200005];
struct t {
  long long h, id;
  bool operator<(const t a) const { return h > a.h; }
} ans;
set<t> a[400005];
long long g, d, tot, h, w, n, dp[100005];
bool cmp(p a, p b) {
  if (a.h == b.h) return a.opt < b.opt;
  return a.h < b.h;
}
void update(long long k, long long l, long long r, long long x, long long y,
            long long opt) {
  long long mid = (l + r) / 2;
  if (l == x && r == y) {
    if (opt == 0)
      a[k].erase((t){g, d});
    else
      a[k].insert((t){g, d});
    return;
  }
  if (mid >= y)
    update(k << 1, l, mid, x, y, opt);
  else if (mid < x)
    update(k << 1 | 1, mid + 1, r, x, y, opt);
  else {
    update(k << 1, l, mid, x, mid, opt);
    update(k << 1 | 1, mid + 1, r, mid + 1, y, opt);
  }
}
void query(long long k, long long l, long long r, long long x) {
  if (!a[k].empty()) {
    t temp = *a[k].begin();
    if (temp < ans) ans = temp;
  }
  if (l == r) return;
  long long mid = (l + r) / 2;
  if (mid >= x)
    query(k << 1, l, mid, x);
  else
    query(k << 1 | 1, mid + 1, r, x);
}
long long query(long long x) {
  ans = (t){-1, -1};
  query(1, 1, w, x);
  if (ans.id == -1)
    return 1;
  else
    return dp[ans.id];
}
int main() {
  long long i, u, l, r, s, ans = 0;
  cin >> h >> w >> n;
  for (i = 1; i <= n; i++) {
    cin >> u >> l >> r >> s;
    e[i] = (xy){u, l, r, s};
    b[++tot] = (p){i, u, 1};
    if (u + s <= h) b[++tot] = (p){i, u + s + 1, 0};
  }
  sort(b + 1, b + 1 + tot, cmp);
  for (i = 1; i <= tot; i++) {
    d = b[i].id;
    xy now = e[d];
    g = now.h;
    if (b[i].opt == 0) {
      update(1, 1, w, now.l, now.r, 0);
    } else {
      if (now.l == 1)
        dp[d] = query(now.r + 1) * 2 % 1000000007;
      else if (now.r == w)
        dp[d] = query(now.l - 1) * 2 % 1000000007;
      else
        (dp[d] = query(now.l - 1) + query(now.r + 1)) %= 1000000007;
      update(1, 1, w, now.l, now.r, 1);
    }
  }
  for (i = 1; i <= w; i++) {
    ans = (ans + query(i)) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
