#include <bits/stdc++.h>   using namespace std;   static const int INF = 0x3f3f3f3f;   static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;   template <typename T>   T mulmod(T a, T b, T m) {     long long int q =         (long long int)(((long double)a * (long double)b) / (long double)m);     long long int r = a * b - q * m;     if (r > m) r %= m;     if (r < 0) r += m;     return r;   }   template <typename T>   T MOD(T a, T b) {     return (a < b ? a : a % b);   }   template <typename T>   T expo(T e, T n) {     T x = 1, p = e;     while (n) {       if (n & 1) x = x * p;       p = p * p;       n >>= 1;     }     return x;   }   template <typename T>   T power(T e, T n, T m) {     T x = 1, p = e;     while (n) {       if (n & 1) x = mulmod(x, p, m);       p = mulmod(p, p, m);       n >>= 1;     }     return x;   }   template <typename T>   T gcd(T a, T b) {     if (a % b) return gcd(b, a % b);     return b;   }   template <typename T>   T lcm(T a, T b) {     return (a * (b / gcd(a, b)));   }   template <typename T>   T add(T a, T b, T Mod) {     a += b;     return (a >= Mod ? a - Mod : a);   }   template <typename T>   T sub(T a, T b, T Mod) {     a -= b;     return (a < 0 ? a + Mod : a);   }   const int Mod = 1000000007;   const int N = 100005;   int MX = 1000001;   int a[N];   struct segmentTree {     int tree[6 * N];     int lazy[6 * N];     void modify(int node, int v) {       tree[node] += v;       lazy[node] += v;     }     void update(int node, int x, int y, int p, int q, int val) {       if (lazy[node]) {         modify(node << 1, lazy[node]);         modify(node << 1 | 1, lazy[node]);         lazy[node] = 0;       }       if (x >= p and y <= q) {         modify(node, val);         return;       }       int mid = x + y >> 1;       if (p <= mid) update(node << 1, x, mid, p, q, val);       if (q > mid) update(node << 1 | 1, mid + 1, y, p, q, val);       tree[node] = max(tree[node << 1], tree[node << 1 | 1]);     }     int query(int node, int x, int y) {       if (lazy[node]) {         modify(node << 1, lazy[node]);         modify(node << 1 | 1, lazy[node]);         lazy[node] = 0;       }       if (tree[node] <= 0) return -1;       if (x == y) return a[x];       int mid = x + y >> 1;       int ret = query(node << 1 | 1, mid + 1, y);       if (ret == -1) {         ret = query(node << 1, x, mid);       }       return ret;     }   } T;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int m;     cin >> m;     for (int i = 0; i <= m - 1; i++) {       int p, t;       cin >> p >> t;       if (t == 0) {         T.update(1, 1, m, 1, p, -1);       } else {         int x;         cin >> x;         a[p] = x;         T.update(1, 1, m, 1, p, 1);       }       cout << T.query(1, 1, m) <<   n ;     }     return 0;   }   