func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const int N = 1000010;   template <class T>   class BIT {     T bit[N + 1];     int n;       public:     BIT() {       n = N;       memset(bit, 0, sizeof(bit));     }     T sum(int i) {       T s = 0;       ++i;       while (i > 0) {         s += bit[i];         s %= MOD;         i -= i & -i;       }       return s;     }     void add(int i, T x) {       ++i;       while (i <= n) {         bit[i] += x;         bit[i] %= MOD;         i += i & -i;       }     }   };   BIT<long long> T;   int n, m, k;   vector<pair<int, int>> in[1000010];   vector<pair<int, int>> out[1000010];   set<int> alive;   set<pair<int, int>> itv;   int main() {     scanf( %d %d %d , &n, &m, &k);     alive.insert(1);     itv.insert(make_pair(0, 0));     for (int i = 0; i < (k); i++) {       int a, b, c, d;       scanf( %d %d %d %d , &a, &b, &c, &d);       in[b].push_back(make_pair(a, c));       out[d + 1].push_back(make_pair(a, c));     }     T.add(1, 1);     for (int i = 1; i <= m; ++i)       if (in[i].size() > 0 || out[i].size() > 0) {         sort((in[i]).begin(), (in[i]).end());         sort((out[i]).begin(), (out[i]).end());         vector<pair<int, long long>> vals;         for (int j = 0; j < (in[i].size()); j++) {           pair<int, int> p = in[i][j];           auto it = itv.upper_bound(make_pair(p.second + 1, n));           --it;           if (it->second < p.second + 1) {             long long num = T.sum(p.second) - T.sum(it->second);             num %= MOD;             if (num < 0) num += MOD;             vals.emplace_back(p.second + 1, i > 1 ? num : 0LL);             if (i > 1) alive.insert(p.second + 1);           }         }         for (pair<int, int> p : out[i]) {           itv.erase(p);         }         for (int j = 0; j < (vals.size()); j++) {           T.add(vals[j].first, vals[j].second);         }         for (int j = 0; j < (in[i].size()); j++) {           pair<int, int> p = in[i][j];           itv.insert(p);           auto it = alive.lower_bound(p.first);           while (it != alive.end() && *it <= p.second) {             int pos = *it;             long long k = T.sum(pos) - T.sum(pos - 1);             k %= MOD;             T.add(pos, MOD - k);             alive.erase(it++);           }         }       }     long long ret = T.sum(n);     auto it = itv.end();     --it;     ret = (ret - T.sum(it->second)) % MOD;     if (ret < 0) ret += MOD;     printf( %d n , (int)ret);     return 0;   }   