#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
int n;
pair<pair<int, int>, int> a[265009];
void init(int v, int b, int e) {
  a[v] = pair<pair<int, int>, int>(pair<int, int>(0, 0), -1);
  if (e - b > 1) {
    init(v + v, b, (b + e) / 2);
    init(v + v + 1, (b + e) / 2, e);
  }
}
int nth(int v, int b, int e, int p) {
  if (e - b == 1) return a[v].second;
  int l = a[v + v].first.second - a[v + v + 1].first.first;
  if (l <= 0)
    return nth(v + v + 1, (b + e) / 2, e, p);
  else if (p < l)
    return nth(v + v, b, (b + e) / 2, p);
  else
    return nth(v + v + 1, (b + e) / 2, e, p - l);
}
void insert(int v, int b, int e, int p, int t, int xx) {
  if (e - b == 1) {
    if (t)
      a[v] = pair<pair<int, int>, int>(pair<int, int>(0, 1), xx);
    else
      a[v] = pair<pair<int, int>, int>(pair<int, int>(1, 0), -1);
    return;
  }
  int m = (b + e) / 2;
  if (p < m)
    insert(v + v, b, (b + e) / 2, p, t, xx);
  else
    insert(v + v + 1, (b + e) / 2, e, p, t, xx);
  pair<pair<int, int>, int> x = a[v + v];
  pair<pair<int, int>, int> y = a[v + v + 1];
  if (x.first.second >= y.first.first) {
    int ln = (x.first.second - y.first.first);
    int lt;
    if (y.first.second > 0)
      lt = y.second;
    else if (ln == 0)
      lt = -1;
    else
      lt = nth(v, b, e, ln - 1);
    ln += y.first.second;
    a[v] = pair<pair<int, int>, int>(pair<int, int>(x.first.first, ln), lt);
  } else {
    a[v] = pair<pair<int, int>, int>(
        pair<int, int>(x.first.first - x.first.second + y.first.first,
                       y.first.second),
        y.second);
  }
}
int main() {
  while (scanf("%d", &n) == 1) {
    init(1, 0, n);
    for (int(i) = (0); (i) < (n); ++(i)) {
      int p, v, x = -1;
      scanf("%d%d", &p, &v);
      p--;
      if (v == 1) {
        scanf("%d", &x);
      }
      insert(1, 0, n, p, v, x);
      printf("%d\n", a[1].second);
    }
  }
  return 0;
}
