#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double PI = acos(-1);
template <class T, class S>
inline void add(T& a, S b) {
  a += b;
  if (a >= mod) a -= mod;
}
template <class T, class S>
inline void sub(T& a, S b) {
  a -= b;
  if (a < 0) a += mod;
}
template <class T, class S>
inline bool chkmax(T& a, S b) {
  return a < b ? a = b, true : false;
}
template <class T, class S>
inline bool chkmin(T& a, S b) {
  return a > b ? a = b, true : false;
}
int h, w, n;
int toL[N], toR[N];
int to[N];
int hs[N];
set<int> start;
set<pair<int, int> > seg;
int dp[N];
struct Node {
  int u, l, r, s;
  bool operator<(const Node& rhs) const { return u < rhs.u; }
  void read() { scanf("%d%d%d%d", &u, &l, &r, &s); }
} a[N];
vector<pair<int, int> > vc;
struct segmentTree {
  set<pair<int, int> > a[N << 2];
  void Insert(int p, pair<int, int> v, int l, int r, int rt) {
    a[rt].insert(v);
    if (l == r) return;
    int mid = l + r >> 1;
    if (p <= mid)
      Insert(p, v, l, mid, rt << 1);
    else
      Insert(p, v, mid + 1, r, rt << 1 | 1);
  }
  void Delete(int p, pair<int, int> v, int l, int r, int rt) {
    a[rt].erase(v);
    if (l == r) return;
    int mid = l + r >> 1;
    if (p <= mid)
      Delete(p, v, l, mid, rt << 1);
    else
      Delete(p, v, mid + 1, r, rt << 1 | 1);
  }
  void query(int L, int R, int x, int y, int l, int r, int rt) {
    if (R < l || r < L || R < L) return;
    if (L <= l && r <= R) {
      auto it = a[rt].lower_bound(make_pair(x, -inf));
      while (it != a[rt].end() && it->first <= y) {
        vc.push_back(*it);
        ++it;
      }
      return;
    }
    int mid = l + r >> 1;
    query(L, R, x, y, l, mid, rt << 1);
    query(L, R, x, y, mid + 1, r, rt << 1 | 1);
  }
} Tree;
int main() {
  scanf("%d%d%d", &h, &w, &n);
  for (int i = 1; i <= w; i++) start.insert(i);
  for (int i = 1; i <= n; i++) a[i].read();
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) hs[i] = a[i].u;
  for (int i = n; i >= 1; i--) {
    if (a[i].u + a[i].s < h + 1) continue;
    while (1) {
      auto it = start.lower_bound(a[i].l);
      if (it == start.end() || *it > a[i].r) break;
      to[*it] = i;
      start.erase(it);
    }
  }
  for (int i = n; i >= 1; i--) {
    int p = upper_bound(hs + 1, hs + 1 + n, a[i].u + a[i].s) - hs - 1;
    Tree.query(i + 1, p, a[i].l, a[i].r, 1, n, 1);
    for (auto& t : vc) {
      if (t.second < 0)
        toL[-t.second] = i;
      else
        toR[t.second] = i;
      Tree.Delete(abs(t.second), t, 1, n, 1);
    }
    if (a[i].l - 1 > 0) Tree.Insert(i, make_pair(a[i].l - 1, -i), 1, n, 1);
    if (a[i].r + 1 <= w) Tree.Insert(i, make_pair(a[i].r + 1, i), 1, n, 1);
    vc.clear();
  }
  for (int i = 1; i <= n; i++) {
    if (a[i].l == 1) toL[i] = toR[i];
    if (a[i].r == w) toR[i] = toL[i];
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i] = (dp[toL[i]] + dp[toR[i]]) % mod;
  }
  int ans = 0;
  for (int i = 1; i <= w; i++) add(ans, dp[to[i]]);
  printf("%d\n", ans);
  return 0;
}
