func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 2000000;   int xx[1111111], yy[1111111];   int pos[1111111], n, m, op[1111111], np[1111111], ff;   int owner[3333333], first[3333333];   int ans[1111111];   bool used[1111111];   void imp() {     puts( -1 );     exit(0);   }   inline int sum(int x) {     int r = 0;     while (x >= 0) {       r += first[x];       x = (x & (x + 1)) - 1;     }     return r;   }   inline void add(int x, int d) {     while (x <= maxn) {       first[x] += d;       x = (x | (x + 1));     }   }   inline int getFirst(int x) {     int l = -1, r = maxn;     while (r - l > 1) {       int mid = ((l + r) >> 1);       if (sum(mid) >= x) {         r = mid;       } else {         l = mid;       }     }     return r;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       scanf( %d%d , &xx[i], &yy[i]);       --xx[i];     }     memset(owner, -1, sizeof(owner));     memset(pos, -1, sizeof(pos));     int ff = m;     for (int i = 1; i <= n; ++i) {       add(ff + i, 1);     }     for (int i = 0; i < m; ++i) {       int &oldPlace = op[i];       int &newPlace = np[i];       int &x = xx[i];       int &y = yy[i];       oldPlace = getFirst(y);       if ((pos[x] != -1 && oldPlace != pos[x]) ||           (owner[oldPlace] != -1 && owner[oldPlace] != x)) {         imp();       }       newPlace = ff--;       owner[oldPlace] = -1;       add(oldPlace, -1);       add(newPlace, 1);       pos[x] = newPlace;       owner[newPlace] = x;     }     for (int i = m - 1; i >= 0; --i) {       int &oldPlace = op[i];       int &newPlace = np[i];       int &x = xx[i];       int &y = yy[i];       pos[x] = oldPlace;       owner[oldPlace] = x;       add(oldPlace, 1);       owner[newPlace] = -1;       add(newPlace, -1);     }     memset(ans, -1, sizeof(ans));     for (int i = 0; i < n; ++i)       if (pos[i] != -1) {         int p = sum(pos[i]);         ans[p - 1] = i;         used[i] = true;       }     int fx = 0;     for (int i = 0; i < n; ++i)       if (ans[i] == -1) {         while (used[fx]) {           ++fx;         }         ans[i] = fx;         used[fx] = true;       }     for (int i = 0; i < n; ++i) {       if (i > 0) {         putchar(   );       }       printf( %d , ans[i] + 1);     }     puts(  );     return 0;   }   