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;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline long long inc(int &x) { return ++x; }
inline long long inc(long long &x) { return ++x; }
inline long long inc(int &x, long long y) { return x += y; }
inline long long inc(long long &x, long long y) { return x += y; }
inline double inc(double &x, double y) { return x += y; }
inline long long dec(int &x) { return --x; }
inline long long dec(long long &x) { return --x; }
inline long long dec(int &x, long long y) { return x -= y; }
inline long long dec(long long &x, long long y) { return x -= y; }
inline double dec(double &x, double y) { return x -= y; }
inline long long mul(int &x) { return x = ((long long)x) * x; }
inline long long mul(long long &x) { return x = x * x; }
inline long long mul(int &x, long long y) { return x *= y; }
inline long long mul(long long &x, long long y) { return x *= y; }
inline double mul(double &x, double y) { return x *= y; }
inline long long divi(const int &x) {
  long long ans, l, r, mid;
  ans = 0;
  l = 0;
  r = 0x3fffffff;
  while (l < r) {
    mid = (l + r) / 2;
    if (mid * mid <= x) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid;
  }
  return ans;
}
inline long long divi(const long long &x) {
  long long ans, l, r, mid;
  ans = 0;
  l = 0;
  r = 0x3fffffff;
  while (l < r) {
    mid = (l + r) / 2;
    if (mid * mid <= x) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid;
  }
  return ans;
}
inline long long divi(int &x, long long y) { return x /= y; }
inline long long divi(long long &x, long long y) { return x /= y; }
inline double divi(double &x, double y) { return x /= y; }
inline long long mod(int &x, long long y) { return x %= y; }
inline long long mod(long long &x, long long y) { return x %= y; }
long long n, m, i, j, x, y, z, seq[100005];
struct seg {
  struct nd {
    int l, r, sum, ad;
  } tr[400005];
  void pushup(int x) {
    tr[x].sum = max(tr[((x) << 1)].sum, tr[(((x) << 1) | 1)].sum);
  }
  void pushdo(int x) {
    if (!tr[x].ad) return;
    tr[((x) << 1)].sum += tr[x].ad;
    tr[((x) << 1)].ad += tr[x].ad;
    tr[(((x) << 1) | 1)].sum += tr[x].ad;
    tr[(((x) << 1) | 1)].ad += tr[x].ad;
    tr[x].ad = 0;
  }
  void build(int x, int l, int r) {
    tr[x].l = l;
    tr[x].r = r;
    tr[x].sum = tr[x].ad = 0;
    if (l == r) return;
    build(x * 2, l, (l + r) / 2);
    build(x * 2 + 1, (l + r) / 2 + 1, r);
    pushup(x);
  }
  void update(int x, int l, int r, int c) {
    if (tr[x].r < l || tr[x].l > r) return;
    if (l <= tr[x].l && tr[x].r <= r) {
      tr[x].sum += c;
      tr[x].ad += c;
      return;
    }
    pushdo(x);
    update(((x) << 1), l, r, c);
    update((((x) << 1) | 1), l, r, c);
    pushup(x);
  }
  int query(int x, int l, int r) {
    if (tr[x].r < l || tr[x].l > r) return 0;
    if (tr[x].sum <= 0) return 0;
    if (tr[x].l == tr[x].r) {
      if (tr[x].sum > 0) return tr[x].r;
      return 0;
    }
    pushdo(x);
    if (tr[(((x) << 1) | 1)].sum > 0) return query((((x) << 1) | 1), l, r);
    return query(((x) << 1), l, r);
  }
} tr;
int main() {
  scanf("%d", &n);
  tr.build(1, 1, n);
  seq[0] = -1;
  if ((1) <= ((n)))
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
      scanf("%d%d", &x, &y);
      if (y == 1) {
        scanf("%d", &z);
        seq[x] = z;
        tr.update(1, 1, x, 1);
      } else {
        tr.update(1, 1, x, -1);
      }
      printf("%d\n", seq[tr.query(1, 1, n)]);
    }
  return 0;
}
