func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, sol[1000005];   struct ell {     int dr, cnt, poz;     bool operator<(const ell &A) const { return dr < A.dr; }   };   multiset<ell> Q;   struct el {     int x, y, flag, cnt, poz;     bool operator<(const el &A) const {       if (x == A.x) {         if (y == A.y) return flag > A.flag;         return y > A.y;       }       return x < A.x;     }   };   el a[1000005], b[1000005];   int main() {     int i, j, cn;     ell w;     cin.sync_with_stdio(0);     cin >> n;     cn = n;     for (i = 1; i <= n; ++i) {       cin >> a[i].x >> a[i].y;       a[i].poz = i;       b[i] = a[i];     }     cin >> m;     for (i = 1; i <= m; ++i) {       cin >> a[n + i].x >> a[n + i].y >> a[n + i].cnt;       a[n + i].flag = 1;       a[n + i].poz = i;       b[n + i] = a[n + i];     }     n += m;     sort(a + 1, a + n + 1);     for (i = 1; i <= n; ++i) {       if (a[i].flag) {         w.dr = a[i].y;         w.cnt = a[i].cnt;         w.poz = a[i].poz;         Q.insert(w);       } else {         ell w;         w.dr = a[i].y;         multiset<ell>::iterator it = Q.lower_bound(w);         if (it == Q.end()) {           printf( NO n );           return 0;         }         sol[a[i].poz] = it->poz;         --b[it->poz + cn].cnt;         if (!b[it->poz + cn].cnt) Q.erase(it);       }     }     cout <<  YES n ;     for (i = 1; i <= n - m; ++i) cout << sol[i] <<    ;     return 0;   }   