func_code_string: #include <bits/stdc++.h>   using namespace std;   int pen[2000005];   void update(int ind, int add) {     while (ind < 2000005) {       pen[ind] += add;       ind += ind & (-ind);     }   }   int query(int ind) {     int ret = 0;     while (ind > 0) {       ret = ret + pen[ind];       ind = ind & (ind - 1);     }     return ret;   }   pair<int, int> r[2000005];   bool vis[2000005];   int getIndex(int y) {     int sum = 0;     int ind = 0;     for (int i = 20; i >= 0; --i) {       int nind = ind + (1 << i);       if (nind < 2000005) {         int nsum = sum + pen[nind];         if (nsum < y) {           sum = nsum;           ind = nind;         }       }     }     return ind + 1;   }   int out[2000005];   int mapping[2000005];   void solve() {     int n, m;     scanf(  %d %d  , &n, &m);     int pos = m + 1;     for (int i = 1; i <= n; ++i) {       r[pos + i] = {-1, i};       update(pos + i, 1);     }     for (int i = 0; i < m; ++i) {       int x, y;       scanf( %d %d  , &x, &y);       int ind = getIndex(y);       if (vis[x]) {         if (r[ind].first != x) {           printf( -1 n );           return;         }       } else {         if (r[ind].first != -1) {           printf( -1 n );           return;         }       }       update(ind, -1);       update(pos, 1);       r[pos] = r[ind];       r[pos].first = x;       vis[x] = true;       --pos;     }     int p = 1;     for (int i = 1; i <= n; ++i) {       int ind = getIndex(i);       if (r[ind].first == -1) {         while (p <= n) {           if (vis[p]) {             ++p;           } else {             break;           }         }         r[ind].first = p++;       }       out[r[ind].second] = r[ind].first;     }     for (int i = 1; i <= n; ++i) {       printf( %d  , out[i]);     }   }   int main() {     solve();     return 0;   }   