#include <bits/stdc++.h>
using namespace std;
const int DIM = 400005;
const int INF = 1000000007;
const int MOD = 1000000007;
struct str {
  int h, l, r, s;
} seg[DIM];
int upd[DIM], dp[DIM];
set<pair<int, int>> sgt[DIM];
inline bool cmp(int x, int y) {
  int h1 = x > 0 ? seg[x].h : seg[-x].h + seg[-x].s;
  int h2 = y > 0 ? seg[y].h : seg[-y].h + seg[-y].s;
  if (h1 != h2)
    return h1 < h2;
  else
    return x > y;
}
void update(int nd, int le, int ri, int st, int en, pair<int, int> pr,
            bool ok) {
  if (st <= le and ri <= en) {
    if (ok)
      sgt[nd].insert(pr);
    else
      sgt[nd].erase(sgt[nd].find(pr));
  } else {
    int md = (le + ri) / 2;
    if (st <= md) update(nd * 2, le, md, st, en, pr, ok);
    if (md < en) update(nd * 2 + 1, md + 1, ri, st, en, pr, ok);
  }
}
pair<int, int> query(int nd, int le, int ri, int ps) {
  pair<int, int> ans = sgt[nd].size() ? *sgt[nd].rbegin() : make_pair(-1, -1);
  if (le != ri) {
    int md = (le + ri) / 2;
    if (ps <= md) ans = max(ans, query(nd * 2, le, md, ps));
    if (md < ps) ans = max(ans, query(nd * 2 + 1, md + 1, ri, ps));
  }
  return ans;
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int h, w, n, k = 0, ans = 0;
  cin >> h >> w >> n;
  seg[0] = {0, 1, w, INF};
  for (int i = 1; i <= n; ++i) {
    cin >> seg[i].h >> seg[i].l >> seg[i].r >> seg[i].s;
    upd[++k] = i;
    upd[++k] = -i;
  }
  sort(upd + 1, upd + k + 1, cmp);
  dp[0] = 1;
  for (int i = 0; i <= k + 1; ++i) {
    int p = upd[i];
    if (i == k + 1 or (p < 0 and seg[-p].h + seg[-p].s > h)) {
      for (int i = 1; i <= w; ++i)
        ans = (ans + dp[query(1, 1, w, i).second]) % MOD;
      cout << ans << endl;
      break;
    }
    if (p < 0)
      update(1, 1, w, seg[-p].l, seg[-p].r, make_pair(seg[-p].h, -p), false);
    else {
      if (p)
        dp[p] = (dp[query(1, 1, w, seg[p].l == 1 ? seg[p].r + 1 : seg[p].l - 1)
                        .second] +
                 dp[query(1, 1, w, seg[p].r == w ? seg[p].l - 1 : seg[p].r + 1)
                        .second]) %
                MOD;
      update(1, 1, w, seg[p].l, seg[p].r, make_pair(seg[p].h, p), true);
    }
  }
  return 0;
}
