Nikita has a stack. A stack in this problem is a data structure that supports two operations. Operation push(x) puts an integer x on the top of the stack, and operation pop() deletes the top integer from the stack, i. e. the last added. If the stack is empty, then the operation pop() does nothing.

Nikita made m operations with the stack but forgot them. Now Nikita wants to remember them. He remembers them one by one, on the i-th step he remembers an operation he made pi-th. In other words, he remembers the operations in order of some permutation p1, p2, ..., pm. After each step Nikita wants to know what is the integer on the top of the stack after performing the operations he have already remembered, in the corresponding order. Help him!

Input

The first line contains the integer m (1 ≤ m ≤ 105) — the number of operations Nikita made.

The next m lines contain the operations Nikita remembers. The i-th line starts with two integers pi and ti (1 ≤ pi ≤ m, ti = 0 or ti = 1) — the index of operation he remembers on the step i, and the type of the operation. ti equals 0, if the operation is pop(), and 1, is the operation is push(x). If the operation is push(x), the line also contains the integer xi (1 ≤ xi ≤ 106) — the integer added to the stack.

It is guaranteed that each integer from 1 to m is present exactly once among integers pi.

Output

Print m integers. The integer i should equal the number on the top of the stack after performing all the operations Nikita remembered on the steps from 1 to i. If the stack is empty after performing all these operations, print -1.

Examples

Input

2
2 1 2
1 0


Output

2
2


Input

3
1 1 2
2 1 3
3 0


Output

2
3
2


Input

5
5 0
4 0
3 1 1
2 1 1
1 1 2


Output

-1
-1
-1
-1
2

Note

In the first example, after Nikita remembers the operation on the first step, the operation push(2) is the only operation, so the answer is 2. After he remembers the operation pop() which was done before push(2), answer stays the same.

In the second example, the operations are push(2), push(3) and pop(). Nikita remembers them in the order they were performed.

In the third example Nikita remembers the operations in the reversed order.
#include <bits/stdc++.h>
using namespace std;
int mas[100100];
const int MAXN = 1 << 17;
const int MAXN2 = MAXN * 2;
int tree[MAXN2];
int treeres[MAXN2];
void adfsadsad(int idx, int L, int R, int pos, int val) {
  if (L == R) {
    tree[idx] = val;
    treeres[idx] = val;
    return;
  }
  int mid = (L + R) / 2;
  if (pos <= mid)
    adfsadsad(idx * 2, L, mid, pos, val);
  else
    adfsadsad(idx * 2 + 1, mid + 1, R, pos, val);
  tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
  treeres[idx] =
      max(tree[idx * 2 + 1] + treeres[idx * 2], treeres[idx * 2 + 1]);
}
void setvalue(int pos) { adfsadsad(1, 0, MAXN - 1, pos, 1); }
void ervalue(int pos) { adfsadsad(1, 0, MAXN - 1, pos, -1); }
int get(int idx, int L, int R, int cursum) {
  if (L == R) {
    if (cursum + tree[idx] > 0)
      return L;
    else
      return -1;
  }
  int mid = (L + R) / 2;
  if (cursum + treeres[idx * 2 + 1] > 0)
    return get(idx * 2 + 1, mid + 1, R, cursum);
  else
    return get(idx * 2, L, mid, cursum + tree[idx * 2 + 1]);
}
int solve() { return get(1, 0, MAXN - 1, 0); }
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int p, t;
    scanf("%d %d", &p, &t);
    if (t == 1) {
      int x;
      scanf("%d", &x);
      mas[p] = x;
      setvalue(p);
    } else {
      ervalue(p);
    }
    int s = solve();
    if (s != -1) s = mas[s];
    printf("%d\n", s);
  }
  return 0;
}
