func_code_string: #include <bits/stdc++.h>   using namespace std;   pair<int, int> St[5 * (int)(2e5 + 10)], arr[(int)(2e5 + 10)],       A[(int)(2e5 + 10)];   int ans[(int)(2e5 + 10)], t[(int)(2e5 + 10)], b[(int)(2e5 + 10)];   int i, j, k, n, m, x, y, z;   vector<pair<int, pair<int, int> > > v;   vector<int> v2;   map<int, int> H;   pair<int, int> que(int root, int bas, int son, int x, int y) {     if (bas > y or son < x) return make_pair(0, 0);     if (x <= bas and son <= y) return St[root];     return max(que((root << 1), bas, ((bas + son) >> 1), x, y),                que(((root << 1) | 1), ((bas + son) >> 1) + 1, son, x, y));   }   pair<int, int> upd(int root, int bas, int son, int x, pair<int, int> t) {     if (bas > x or son < x) return St[root];     if (bas == son) return St[root] = t;     return St[root] =                max(upd((root << 1), bas, ((bas + son) >> 1), x, t),                    upd(((root << 1) | 1), ((bas + son) >> 1) + 1, son, x, t));   }   int main() {     cin >> n >> m;     for (i = 1; i <= n; i++) {       scanf( %d %d %d , &arr[i].first, &arr[i].second, t + i);       v2.push_back(t[i]);       v.push_back(make_pair(arr[i].first, make_pair(0, i)));     }     for (i = 1; i <= m; i++) {       scanf( %d %d %d , &A[i].first, &A[i].second, b + i);       v2.push_back(b[i]);       v.push_back(make_pair(A[i].first, make_pair(1, i)));     }     sort(v2.begin(), v2.end());     int s = 0;     H[v2[0]] = ++s;     for (i = 1; i < v2.size(); i++) {       if (v2[i] != v2[i - 1]) H[v2[i]] = ++s;     }     sort(v.begin(), v.end());     for (i = 0; i < v.size(); i++) {       int x = v[i].second.second;       int p = v[i].second.first;       if (p) {         int bas = H[b[x]];         int son = s;         while (bas < son) {           if (que(1, 1, s, H[b[x]], ((bas + son) >> 1)).first >= A[x].second)             son = ((bas + son) >> 1);           else             bas = ((bas + son) >> 1) + 1;         }         pair<int, int> a = que(1, 1, s, H[b[x]], bas);         if (a.first >= A[x].second) ans[x] = a.second;       } else         upd(1, 1, s, H[t[x]], make_pair(arr[x].second, x));     }     for (i = 1; i <= m; i++) {       if (ans[i])         cout << ans[i] <<    ;       else         cout << -1 <<    ;     }     cout <<   n ;   }   