func_code_string: #include <bits/stdc++.h>   using namespace std;   const int D = 1000005;   const int N = 100005;   const int mo = 1000000007;   int tg[D * 3], sum[D * 3];   void pushdown(int k) {     if (!tg[k]) return;     sum[k * 2] = sum[k * 2 + 1] = 0;     tg[k * 2] = tg[k * 2 + 1] = 1;     tg[k] = 0;   }   void pushup(int k) { sum[k] = (sum[k * 2] + sum[k * 2 + 1]) % mo; }   void change(int k, int l, int r, int p, int v) {     if (l == r) return sum[k] = v, void(0);     int mid = (l + r) / 2;     pushdown(k);     if (p <= mid)       change(k * 2, l, mid, p, v);     else       change(k * 2 + 1, mid + 1, r, p, v);     pushup(k);   }   void cover(int k, int l, int r, int x, int y) {     if (l == x && r == y) {       tg[k] = 1;       sum[k] = 0;       return;     }     int mid = (l + r) / 2;     pushdown(k);     if (y <= mid)       cover(k * 2, l, mid, x, y);     else if (x > mid)       cover(k * 2 + 1, mid + 1, r, x, y);     else       cover(k * 2, l, mid, x, mid), cover(k * 2 + 1, mid + 1, r, mid + 1, y);     pushup(k);   }   int ask(int k, int l, int r, int x, int y) {     if (l == x && r == y) return sum[k];     int mid = (l + r) / 2;     pushdown(k);     if (y <= mid) return ask(k * 2, l, mid, x, y);     if (x > mid) return ask(k * 2 + 1, mid + 1, r, x, y);     return (ask(k * 2, l, mid, x, mid) + ask(k * 2 + 1, mid + 1, r, mid + 1, y)) %            mo;   }   struct rect {     int x, y, X, Y, v;   } a[N];   vector<int> IN[D], OUT[D];   set<pair<int, int> > s;   int n, m, k;   bool cmp(rect a, rect b) { return a.y < b.y; }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = (int)(1); i <= (int)(k); i++)       scanf( %d%d%d%d , &a[i].x, &a[i].y, &a[i].X, &a[i].Y);     sort(a + 1, a + k + 1, cmp);     for (int i = (int)(1); i <= (int)(k); i++) {       IN[a[i].x].push_back(i);       OUT[a[i].X + 1].push_back(i);     }     s.insert(pair<int, int>(0, 0));     for (int i = (int)(1); i <= (int)(n); i++) {       if (IN[i].size()) {         int sz = IN[i].size();         for (int j = (int)(0); j <= (int)(sz - 1); j++) {           int id = IN[i][j];           int id2 = (*s.lower_bound(pair<int, int>(-a[id].Y - 1, 0))).second;           if (a[id2].Y < a[id].Y + 1 && a[id].Y < m)             a[id].v = ask(1, 1, m, a[id2].Y + 1, a[id].Y + 1);           else             a[id].v = -1;         }         for (int j = (int)(0); j <= (int)(sz - 1); j++) {           int id = IN[i][j];           if (a[id].v >= 0) change(1, 1, m, a[id].Y + 1, a[id].v);           cover(1, 1, m, a[id].y, a[id].Y);           s.insert(pair<int, int>(-a[id].Y, id));           s.insert(pair<int, int>(-a[id].y, id));         }       }       if (OUT[i].size()) {         int sz = OUT[i].size();         for (int j = (int)(0); j <= (int)(sz - 1); j++) {           int id = OUT[i][j];           s.erase(pair<int, int>(-a[id].Y, id));           s.erase(pair<int, int>(-a[id].y, id));         }       }       if (i == 1) change(1, 1, m, 1, 1);     }     int u = -(*s.lower_bound(pair<int, int>(-m, 0))).first;     printf( %d n , ask(1, 1, m, u + 1, m));   }   