#include <bits/stdc++.h>
using namespace std;
int m, boxsize, offset[1001], big[1001];
vector<int> v[1001];
void cal(int idx) {
  int ret = 0;
  big[idx] = 0;
  for (int i = v[idx].size() - 1; i >= 0; i--) {
    if (v[idx][i] > 0) {
      ++ret;
      big[idx] = max(big[idx], ret);
    } else if (v[idx][i] < 0)
      --ret;
  }
  offset[idx] = ret;
}
int find(int box, int nowsum) {
  for (int i = v[box].size() - 1; i >= 0; i--) {
    if (v[box][i] > 0) {
      ++nowsum;
      if (nowsum > 0) {
        return v[box][i];
      }
    } else if (v[box][i] < 0)
      --nowsum;
  }
}
int getans() {
  int ret = 0;
  for (int i = boxsize + 1; i >= 0; i--) {
    if (ret + big[i] > 0) {
      return find(i, ret);
    }
    ret += offset[i];
  }
  return -1;
}
int main() {
  scanf("%d", &m);
  boxsize = sqrt(m);
  for (int i = 0; i <= boxsize + 1; i++) v[i].resize(boxsize, 0);
  for (int op, p, x, i = 0; i < m; i++) {
    scanf("%d %d", &op, &p);
    --op;
    int boxnum = op / boxsize;
    int pos = (op - boxnum * boxsize);
    if (p == 1) {
      scanf("%d", &x);
      v[boxnum][pos] = x;
    } else {
      v[boxnum][pos] = -1;
    }
    cal(boxnum);
    int ret = getans();
    printf("%d\n", ret);
  }
}
