#include <bits/stdc++.h>
const int MAX_H = 2000000001;
const int MAX_W = 100000;
const int MAX_N = 100000;
const int MOD = 1000000007;
struct Barrier {
  int u;
  int l;
  int r;
  int s;
  bool operator<(const Barrier& other) const { return this->u < other.u; }
};
struct Query {
  int min;
  int minIndex;
  bool operator<(const Query& other) const { return this->min < other.min; }
};
struct ArbInt {
  Query query;
  ArbInt* left;
  ArbInt* right;
};
struct Balls {
  int h;
  int count;
  bool operator<(const Balls& other) const { return this->h < other.h; }
};
std::stack<Balls> columns[1 + MAX_W];
Barrier barriers[MAX_N];
ArbInt* build(int begin, int end) {
  if (begin < end) {
    int med = (begin + end + 1) / 2;
    ArbInt* left = build(begin, med - 1);
    ArbInt* right = build(med, end);
    return new ArbInt{std::min(left->query, right->query), left, right};
  } else
    return new ArbInt{Query{columns[begin].top().h, begin}, NULL, NULL};
}
Query queryMin(ArbInt* root, int begin, int end, int l, int r) {
  if (l == begin && end == r)
    return root->query;
  else {
    int med = (begin + end + 1) / 2;
    if (r <= med - 1)
      return queryMin(root->left, begin, med - 1, l, r);
    else if (med <= l)
      return queryMin(root->right, med, end, l, r);
    else
      return std::min(queryMin(root->left, begin, med - 1, l, med - 1),
                      queryMin(root->right, med, end, med, r));
  }
}
void update(ArbInt* root, int begin, int end, int index) {
  if (begin < end) {
    int med = (begin + end + 1) / 2;
    if (index < med)
      update(root->left, begin, med - 1, index);
    else
      update(root->right, med, end, index);
    root->query = std::min(root->left->query, root->right->query);
  } else
    root->query.min = columns[begin].top().h;
}
int main(void) {
  int h, w, n;
  scanf("%d%d%d", &h, &w, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &barriers[i].u, &barriers[i].l, &barriers[i].r,
          &barriers[i].s);
  }
  std::sort(barriers, barriers + n);
  std::reverse(barriers, barriers + n);
  for (int i = 1; i <= w; i++) {
    columns[i].push(Balls{MAX_H, 0});
    columns[i].push(Balls{h + 1, 1});
  }
  ArbInt* root = build(1, w);
  for (int i = 0; i < n; i++) {
    int count = 0;
    Query query = queryMin(root, 1, w, barriers[i].l, barriers[i].r);
    while (query.min <= barriers[i].u + barriers[i].s) {
      count = (count + columns[query.minIndex].top().count) % MOD;
      columns[query.minIndex].pop();
      update(root, 1, w, query.minIndex);
      query = queryMin(root, 1, w, barriers[i].l, barriers[i].r);
    }
    int l = barriers[i].l - 1;
    int r = barriers[i].r + 1;
    if (l == 0) l = r;
    if (r == w + 1) r = l;
    columns[l].push(Balls{barriers[i].u, count});
    columns[r].push(Balls{barriers[i].u, count});
    update(root, 1, w, l);
    update(root, 1, w, r);
  }
  int answer = 0;
  for (int i = 1; i <= w; i++) {
    while (!columns[i].empty()) {
      answer = (answer + columns[i].top().count) % MOD;
      columns[i].pop();
    }
  }
  printf("%d\n", answer);
  return 0;
}
