#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, ty, val, idx;
int op[N] = {0};
int bl[N];
stack<pair<int, int> > seq;
stack<int> ans;
class node {
 public:
  int mbal, lz;
} seg[4 * N];
void upd(int id, int l, int r, int v) {
  seg[id].mbal += v;
  seg[id].lz += v;
}
void shift(int id, int l, int r) {
  int mid = (l + r) / 2;
  upd(2 * id, l, mid, seg[id].lz);
  upd(2 * id + 1, mid, r, seg[id].lz);
  seg[id].lz = 0;
}
void built(int id = 1, int l = 0, int r = n) {
  if (r - l < 2) {
    seg[id].mbal = bl[l];
    seg[id].lz = 0;
    return;
  }
  int mid = (l + r) / 2;
  built(2 * id, l, mid);
  built(2 * id + 1, mid, r);
  seg[id].mbal = max(seg[2 * id].mbal, seg[2 * id + 1].mbal);
  seg[id].lz = 0;
}
void update(int x, int v, int id = 1, int l = 0, int r = n) {
  if (r - l < 2) {
    seg[id].mbal += v;
    return;
  }
  shift(id, l, r);
  int mid = (l + r) / 2;
  if (x < mid) {
    update(x, v, 2 * id, l, mid);
  } else {
    update(x, v, 2 * id + 1, mid, r);
    upd(2 * id, l, mid, v);
  }
  seg[id].mbal = max(seg[2 * id].mbal, seg[2 * id + 1].mbal);
}
int query(int x, int y, int id = 1, int l = 0, int r = n) {
  if (y <= l || x >= r) return -100000007;
  if (x <= l && r <= y) {
    return seg[id].mbal;
  }
  shift(id, l, r);
  int mid = (l + r) / 2;
  return max(query(x, y, 2 * id, l, mid), query(x, y, 2 * id + 1, mid, r));
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> idx >> ty;
    if (ty != 0) cin >> val;
    op[idx - 1] = (ty == 0 ? 0 : val);
    seq.push(pair<int, int>(idx - 1, ty));
  }
  bl[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    bl[i] = bl[i + 1] + (op[i] == 0 ? -1 : 1);
  }
  built();
  int st, en, md;
  while (!seq.empty()) {
    st = 0;
    en = n - 1;
    while (st < en) {
      md = (st + en) / 2;
      if (query(md, n) > 0) {
        st = md + 1;
      } else
        en = md - 1;
    }
    while (st >= 0 && query(st, n) <= 0) {
      st--;
    }
    if (st == -1) {
      ans.push(-1);
    } else
      ans.push(op[st]);
    idx = seq.top().first;
    ty = seq.top().second;
    seq.pop();
    update(idx, (ty == 0 ? 1 : -1));
  }
  while (!ans.empty()) {
    cout << ans.top() << '\n';
    ans.pop();
  }
}
