#include <bits/stdc++.h>
using namespace std;
int l[100010 + 5], r[100010 + 5], u[100010 + 5], s[100010 + 5];
vector<int> vec;
vector<int> pool[100010 + 5], ask_pool[100010 + 5];
struct segtree {
  set<int> s[100010 * 4 + 5];
  void chg(int i, int l, int r, int ql, int qr, int x) {
    if (ql <= l && r <= qr) {
      if (x > 0)
        s[i].insert(x);
      else
        s[i].erase(-x);
      return;
    }
    if (r < ql || qr < l) return;
    int mid = (l + r) >> 1;
    chg(i * 2, l, mid, ql, qr, x);
    chg(i * 2 + 1, mid + 1, r, ql, qr, x);
  }
  int ask(int i, int l, int r, int p) {
    int res = 0;
    if (s[i].size()) res = max(res, *s[i].rbegin());
    if (l == r) return res;
    int mid = (l + r) >> 1;
    if (p <= mid)
      res = max(res, ask(i * 2, l, mid, p));
    else
      res = max(res, ask(i * 2 + 1, mid + 1, r, p));
    return res;
  }
} T;
map<int, int> id;
map<pair<int, int>, int> nxt, dp;
int h, w, n;
int dfs(int x, int y) {
  if (dp.find(make_pair(x, y)) != dp.end()) return dp[make_pair(x, y)];
  int i = nxt[make_pair(x, y)], ans = 0;
  if (i == 0) return dp[make_pair(x, y)] = 1;
  if (l[i] == 1)
    ans = (ans + dfs(r[i] + 1, u[i])) % 1000000007;
  else
    ans = (ans + dfs(l[i] - 1, u[i])) % 1000000007;
  if (r[i] != w)
    ans = (ans + dfs(r[i] + 1, u[i])) % 1000000007;
  else
    ans = (ans + dfs(l[i] - 1, u[i])) % 1000000007;
  return dp[make_pair(x, y)] = ans;
}
int main() {
  scanf("%d%d%d", &h, &w, &n);
  for (int i = 1; i <= n; i++) scanf("%d%d%d%d", &u[i], &l[i], &r[i], &s[i]);
  vec.push_back(h + 1);
  for (int i = 1; i <= n; i++) vec.push_back(u[i]);
  sort(vec.begin(), vec.end());
  int N = vec.size();
  for (int i = 1; i <= n; i++) id[u[i]] = i;
  for (int i = 1; i <= n; i++)
    pool[l[i]].push_back(i), pool[r[i] + 1].push_back(-i);
  for (int i = 1; i <= w; i++) ask_pool[i].push_back(h + 1);
  for (int i = 1; i <= n; i++) {
    if (l[i] != 1) ask_pool[l[i] - 1].push_back(u[i]);
    if (r[i] != w) ask_pool[r[i] + 1].push_back(u[i]);
  }
  for (int x = 1; x <= w; x++) {
    for (auto it : pool[x]) {
      int i = abs(it), sgn = it > 0 ? 1 : -1;
      int y1 = lower_bound(vec.begin(), vec.end(), u[i] + 1) - vec.begin() + 1;
      int y2 = upper_bound(vec.begin(), vec.end(), u[i] + s[i]) - vec.begin();
      T.chg(1, 1, N, y1, y2, sgn * u[i]);
    }
    for (auto y : ask_pool[x]) {
      int yid = lower_bound(vec.begin(), vec.end(), y) - vec.begin() + 1;
      int r = T.ask(1, 1, N, yid);
      nxt[make_pair(x, y)] = id[r];
    }
  }
  int ans = 0;
  for (int x = 1; x <= w; x++) ans = (ans + dfs(x, h + 1)) % 1000000007;
  printf("%d\n", ans);
  return 0;
}
