#include <bits/stdc++.h>
using namespace std;
int m;
vector<int> blk[320];
int blkpop[320];
int k = 317;
int a[317 * 318];
int b[317 * 318];
int op, ti, num;
int block;
int i;
int main() {
  int pop;
  scanf("%d", &m);
  int ans;
  while (m--) {
    scanf("%d%d", &ti, &op);
    a[ti] = op + 1;
    ans = -1;
    if (op == 1) {
      scanf("%d", &b[ti]);
      block = ti / k;
      blk[block].clear();
      blkpop[block] = 0;
      pop = 0;
      for (i = block * k; i < k * (block + 1); i++) {
        if (!a[i])
          continue;
        else if (a[i] == 2) {
          blk[block].push_back(b[i]);
        } else {
          if (blk[block].size())
            blk[block].pop_back();
          else
            pop++;
        }
      }
      blkpop[block] = pop;
    } else {
      block = ti / k;
      blk[block].clear();
      blkpop[block] = 0;
      pop = 0;
      for (i = block * k; i < k * (block + 1); i++) {
        if (!a[i])
          continue;
        else if (a[i] == 2) {
          blk[block].push_back(b[i]);
        } else {
          if (blk[block].size())
            blk[block].pop_back();
          else
            pop++;
        }
      }
      blkpop[block] = pop;
    }
    pop = 0;
    for (i = 319; i >= 0; i--)
      if (blk[i].size() && blk[i].size() > pop) {
        ans = blk[i][blk[i].size() - 1 - pop];
        break;
      } else if (blk[i].size())
        pop -= blk[i].size(), pop += blkpop[i];
      else
        pop += blkpop[i];
    printf("%d\n", ans);
  }
  return 0;
}
