#include <bits/stdc++.h>
using namespace std;
const int N = 319;
int m;
int op[(N + 2) * (N + 2)];
int num[(N + 2) * (N + 2)];
vector<int> seg[N + 2];
int pops[N + 2];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> m;
  int sn, p, t, x;
  while (m--) {
    cin >> p >> t;
    op[p] = t + 1;
    sn = p / N;
    seg[sn].clear();
    pops[sn] = 0;
    if (t == 1) {
      cin >> x;
      num[p] = x;
    }
    for (int i = N * sn; i < N * (sn + 1); i++) {
      if (!op[i])
        continue;
      else if (op[i] == 2)
        seg[sn].push_back(num[i]);
      else if (seg[sn].size())
        seg[sn].pop_back();
      else
        pops[sn]++;
    }
    int ans = -1;
    int po = 0;
    for (int i = N; i >= 0; i--) {
      if (seg[i].size() && po < seg[i].size()) {
        ans = seg[i][seg[i].size() - po - 1];
        break;
      } else if (seg[i].size())
        po += pops[i] - seg[i].size();
      else
        po += pops[i];
    }
    cout << ans << endl;
  }
  return 0;
}
