func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   inline T abs(T &a) {     return a > 0 ? a : -a;   }   template <class T>   inline T min(T &a, T &b) {     return a < b ? a : b;   }   template <class T>   inline T max(T &a, T &b) {     return a > b ? a : b;   }   inline void read(int &x) {     char ch;     while ((ch = getchar()) && !(ch >=  0  && ch <=  9 ))       ;     x = ch -  0 ;     while ((ch = getchar()) && (ch >=  0  && ch <=  9 )) x = x * 10 + ch -  0 ;   }   const int N = 2000002;   int n, m, w[N], ans[N], dy[N], T = 1, t[N << 2];   void add(int x, int c) {     for (t[x += T] += c, x >>= 1; x; x >>= 1) t[x] = t[x << 1] + t[(x << 1) + 1];   }   int find(int k, int l, int r) {     int x = 1;     while (l < r) {       int mid = l + r >> 1;       if (t[x << 1] >= k)         x = x << 1, r = mid;       else         k -= t[x << 1], x = x << 1 | 1, l = mid + 1;     }     return l;   }   int main() {     read(n);     read(m);     int Len = n + m, gs = 0;     while (T < Len) T <<= 1, gs++;     T--;     for (int i = m + 1; i <= n + m; i++) w[i] = i - m, add(i, 1);     int x, y;     for (int i = m; i >= 1; i--) {       read(x);       read(y);       int p = find(y, 1, T + 1);       w[i] = w[p];       add(i, 1);       add(p, -1);       if (ans[w[i]] && ans[w[i]] != x) {         puts( -1 );         return 0;       }       ans[w[i]] = x;       if (dy[x] && dy[x] != w[i]) {         puts( -1 );         return 0;       }       dy[x] = w[i];     }     int j = 1;     for (int i = 1; i <= n; i++) {       if (ans[i])         printf( %d  , ans[i]);       else {         for (; dy[j]; j++)           ;         printf( %d  , j++);       }     }   }   