#include <bits/stdc++.h>
using namespace std;
constexpr static int MAXN = 1e6;
constexpr static int BLOCK = 300;
int n, blocks;
int val[MAXN];
int bsize[MAXN], bdel[MAXN];
vector<int> stk[MAXN];
void update_block(int k) {
  int i = k / BLOCK;
  bdel[i] = 0;
  stk[i].clear();
  for (int j = i * BLOCK; j < i * BLOCK + BLOCK && j < n; j++) {
    if (val[j] == 0) continue;
    if (val[j] == -1) {
      if (stk[i].size() > 0)
        stk[i].pop_back();
      else
        bdel[i]++;
    } else {
      stk[i].push_back(val[j]);
    }
  }
  bsize[i] = stk[i].size();
}
int query() {
  vector<pair<int, int>> bstk;
  for (int i = 0; i < blocks; i++) {
    int del = bdel[i];
    while (del > 0) {
      if (bstk.size() == 0) break;
      if (del >= bstk.back().second) {
        del -= bstk.back().second;
        bstk.pop_back();
      } else {
        bstk.back().second -= del;
        del = 0;
      }
    }
    if (bsize[i] > 0) {
      bstk.push_back({i, bsize[i]});
    }
  }
  if (bstk.size() == 0) return -1;
  return stk[bstk.back().first][bstk.back().second - 1];
}
int main() {
  scanf("%d", &n);
  blocks = (n + BLOCK - 1) / BLOCK;
  for (int i = 0; i < n; i++) {
    int p, t;
    scanf("%d%d", &p, &t);
    p--;
    if (t == 0) {
      val[p] = -1;
    } else {
      int x;
      scanf("%d", &x);
      val[p] = x;
    }
    update_block(p);
    printf("%d\n", query());
  }
}
