func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2000020;   pair<int, int> a[N], b[N];   bool comp(int x, int y) { return a[x].second > a[y].second; }   int n, m, K;   vector<int> A[N], B[N];   int g[4 * N];   bool t[4 * N];   long long T[4 * N];   set<pair<int, int> > S;   set<pair<int, int> >::iterator it;   int sum(int v, int tl, int tr, int x) {     if (tl > x || tr <= x) return 0;     if (tl == tr - 1) return g[v];     int xy, yy;     xy = sum(v + v, tl, tl + tr >> 1, x);     yy = sum(v + v + 1, tl + tr >> 1, tr, x);     return max(xy, yy) + g[v];   }   void add(int v, int tl, int tr, int l, int r, int x) {     if (tl >= r || tr <= l) return;     if (l <= tl && tr <= r) {       g[v] += x;       return;     }     add(v + v, tl, tl + tr >> 1, l, r, x);     add(v + v + 1, tl + tr >> 1, tr, l, r, x);   }   void upd1(int v) {     if (t[v]) {       T[v + v] = T[v + v + 1] = T[v];       t[v + v + 1] = t[v + v] = t[v];       t[v] = false;     }   }   void update(int v, int tl, int tr, int l, int r, long long x) {     if (tl >= r || tr <= l) return;     upd1(v);     if (l <= tl && tr <= r) {       T[v] = x;       t[v] = true;       return;     }     update(v + v, tl, tl + tr >> 1, l, r, x);     update(v + v + 1, tl + tr >> 1, tr, l, r, x);     T[v] = (T[v + v] + T[v + v + 1]) % 1000000007ll;   }   long long get(int v, int tl, int tr, int l, int r) {     if (tl >= r || tr <= l) return 0;     upd1(v);     if (l <= tl && tr <= r) return T[v];     long long x, y;     x = get(v + v, tl, tl + tr >> 1, l, r);     y = get(v + v + 1, tl + tr >> 1, tr, l, r);     T[v] = (T[v + v] + T[v + v + 1]) % 1000000007ll;     return (x + y) % 1000000007ll;   }   int main() {     scanf( %d %d %d , &m, &n, &K);     for (int i = 0; i < K; ++i) {       scanf( %d %d , &b[i].first, &a[i].first);       scanf( %d %d , &b[i].second, &a[i].second);       A[b[i].first].push_back(i);       B[b[i].second + 1].push_back(i);     }     update(1, 1, n + 1, 1, 2, 1);     B[1].push_back(K);     a[K].second = n;     a[K].first = 1;     S.insert(make_pair(a[K].second, K));     add(1, 1, n + 1, 1, n + 1, 1);     for (int k = 1; k <= m; ++k) {       sort(A[k].begin(), A[k].end(), comp);       for (int i = 0; i < A[k].size(); ++i) {         int v = A[k][i];         int s = sum(1, 1, n + 1, a[v].second + 1);         if (s == 0) {           it = S.lower_bound(make_pair(a[v].second + 1, 0));           int l = 0;           if (it != S.begin()) {             it--;             l = (*it).first;           }           long long now = get(1, 1, n + 1, l + 1, a[v].second + 2);           now %= 1000000007ll;           update(1, 1, n + 1, a[v].second + 1, a[v].second + 2, now);         }         S.insert(make_pair(a[v].second, v));         add(1, 1, n + 1, a[v].first, a[v].second + 1, 1);         update(1, 1, n + 1, a[v].first, a[v].second + 1, 0);       }       for (int i = 0; i < B[k].size(); ++i) {         int v = B[k][i];         S.erase(make_pair(a[v].second, v));         add(1, 1, n + 1, a[v].first, a[v].second + 1, -1);       }     }     it = S.lower_bound(make_pair(n, 0));     int l = 0;     if (it != S.begin()) {       it--;       l = (*it).first;     }     long long answer = get(1, 1, n + 1, l + 1, n + 1) % 1000000007ll;     printf( %I64d n , answer);   }   