#include <bits/stdc++.h>
using namespace std;
struct Barrier {
  int l, r, h, s;
  Barrier(int l = 0, int r = 0, int h = 0, int s = 0)
      : l(l), r(r), h(h), s(s) {}
};
struct Event {
  int height, type, id;
  Event(int height = 0, int type = 0, int id = 0)
      : height(height), type(type), id(id) {}
};
bool operator<(const Event& A, const Event& B) {
  return A.height < B.height || (A.height == B.height && A.type < B.type);
}
struct Node {
  int h, id;
  Node(int h = 0, int id = 0) : h(h), id(id) {}
};
bool operator<(const Node& A, const Node& B) { return A.h > B.h; }
const int N = 100000;
const int M = N * 4;
const int Mod = 1e9 + 7;
int h, w, n;
Barrier barriers[N + 10];
Event events[N * 2 + 10];
int tot;
set<Node> S[M + 10];
int ans[N + 10];
void modify(int x, int l, int r, int ql, int qr, int op, const Node& node) {
  if (ql <= l && r <= qr) {
    if (op == 0)
      S[x].erase(node);
    else
      S[x].insert(node);
  } else {
    int mid = (l + r) >> 1;
    if (ql <= mid) modify(x << 1, l, mid, ql, qr, op, node);
    if (qr > mid) modify(x << 1 | 1, mid + 1, r, ql, qr, op, node);
  }
}
void query(int x, int l, int r, int p, Node& ans) {
  if (!S[x].empty()) ans = min(ans, *S[x].begin());
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (p <= mid)
    query(x << 1, l, mid, p, ans);
  else
    query(x << 1 | 1, mid + 1, r, p, ans);
}
int query(int p) {
  Node qans = Node(-1, -1);
  query(1, 1, w, p, qans);
  if (qans.id == -1)
    return 1;
  else
    return ans[qans.id];
}
int main() {
  scanf("%d%d%d", &h, &w, &n);
  for (int i = 0; i < n; i++) {
    Barrier& b = barriers[i];
    scanf("%d%d%d%d", &b.h, &b.l, &b.r, &b.s);
    events[tot++] = Event(b.h, 1, i);
    if (b.h + b.s <= h) events[tot++] = Event(b.h + b.s + 1, -1, i);
  }
  sort(events, events + tot);
  for (int i = 0; i < tot; i++) {
    int id = events[i].id;
    Barrier& b = barriers[id];
    if (events[i].type == -1) {
      modify(1, 1, w, b.l, b.r, 0, Node(b.h, id));
    } else {
      if (b.l == 1)
        ans[id] = query(b.r + 1) * 2 % Mod;
      else if (b.r == w)
        ans[id] = query(b.l - 1) * 2 % Mod;
      else
        ans[id] = (query(b.l - 1) + query(b.r + 1)) % Mod;
      modify(1, 1, w, b.l, b.r, 1, Node(b.h, id));
    }
  }
  int sol = 0;
  for (int i = 1; i <= w; i++) (sol += query(i)) %= Mod;
  printf("%d\n", sol);
  return 0;
}
