#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int MAXM = 4e5 + 5;
const int MOD = 1e9 + 7;
int l[MAXM], r[MAXM], x[MAXN], y[MAXN], root;
int u[MAXN], ll[MAXN], rr[MAXN], s[MAXN], pos[MAXN];
int lans[MAXN], rans[MAXN];
vector<int> v[MAXM];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
inline void Add(int &x, int y) { x += y, x >= MOD && (x -= MOD); }
inline void Max(int &x, int y) {
  if (::x[x] < ::x[y]) x = y;
}
void build(int L, int R, int cur) {
  l[cur] = L, r[cur] = R;
  if (L == R) return;
  int mid = (L + R) >> 1;
  build(L, mid, (cur << 1));
  build(mid + 1, R, (cur << 1 | 1));
}
void modify(int ql, int qr, int id, int cur) {
  if (ql <= l[cur] && qr >= r[cur]) {
    while (!v[cur].empty() && y[v[cur].back()] < y[id]) v[cur].pop_back();
    return v[cur].emplace_back(id);
  }
  int mid = (l[cur] + r[cur]) >> 1;
  if (ql <= mid) modify(ql, qr, id, (cur << 1));
  if (qr > mid) modify(ql, qr, id, (cur << 1 | 1));
}
int query(int p, int h, int cur) {
  int ans = 0;
  while (!v[cur].empty() && y[v[cur].back()] < h) v[cur].pop_back();
  if (!v[cur].empty()) ans = v[cur].back();
  if (l[cur] == r[cur]) return ans;
  int mid = (l[cur] + r[cur]) >> 1;
  if (p <= mid) Max(ans, query(p, h, (cur << 1)));
  if (p > mid) Max(ans, query(p, h, (cur << 1 | 1)));
  return ans;
}
inline int calc(int p, int lim) {
  int t = query(p, lim, root);
  return t ? add(lans[t], rans[t]) : 1;
}
int main() {
  int h = read(), w = read();
  int n = read();
  build(1, w, root = 1);
  for (int i = 1; i <= n; i++) {
    u[i] = read(), ll[i] = read();
    rr[i] = read(), s[i] = read();
  }
  auto cmp = [](int x, int y) -> bool { return u[x] < u[y]; };
  for (int i = 1; i <= n; i++) pos[i] = i;
  sort(pos + 1, pos + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    int x = pos[i];
    lans[i] = calc(ll[x] == 1 ? rr[x] + 1 : ll[x] - 1, u[x]);
    rans[i] = calc(rr[x] == w ? ll[x] - 1 : rr[x] + 1, u[x]);
    ::x[i] = u[x], ::y[i] = u[x] + s[x], modify(ll[x], rr[x], i, root);
  }
  int ans = 0;
  for (int i = 1; i <= w; i++) Add(ans, calc(i, h + 1));
  return printf("%d\n", ans), 0;
}
