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 _p__i_\-th. In other words, he remembers the operations in order of some permutation _p_1, _p_2, ..., _p__m_. 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 _p__i_ and _t__i_ (1 ≤ _p__i_ ≤ _m_, _t__i_ = 0 or _t__i_ = 1) — the index of operation he remembers on the step _i_, and the type of the operation. _t__i_ 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 _x__i_ (1 ≤ _x__i_ ≤ 106) — the integer added to the stack.
It is guaranteed that each integer from 1 to _m_ is present exactly once among integers _p__i_.
## 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_.
[samples]
## 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.
Nikita 有一个栈。在本题中,栈是一种支持两种操作的数据结构:操作 _push(x)_ 将整数 #cf_span[x] 放到栈顶,操作 _pop()_ 删除栈顶的整数,即最后加入的元素。如果栈为空,则 _pop()_ 操作不产生任何效果。
Nikita 对栈进行了 #cf_span[m] 次操作,但他忘记了这些操作的具体内容。现在他想逐步回忆起来。在第 #cf_span[i] 步,他回忆起自己在第 #cf_span[pi] 步执行的操作。换句话说,他按照某个排列 #cf_span[p1, p2, ..., pm] 的顺序回忆操作。在每一步之后,Nikita 想知道:在按照已回忆操作的对应顺序执行所有已回忆操作后,栈顶的整数是多少?请你帮助他!
第一行包含整数 #cf_span[m] (#cf_span[1 ≤ m ≤ 105]) —— Nikita 执行的操作次数。
接下来的 #cf_span[m] 行包含 Nikita 回忆的操作。第 #cf_span[i] 行以两个整数 #cf_span[pi] 和 #cf_span[ti] (#cf_span[1 ≤ pi ≤ m], #cf_span[ti = 0] 或 #cf_span[ti = 1]) 开头,分别表示他在第 #cf_span[i] 步回忆的操作的编号,以及操作类型。若 #cf_span[ti] 等于 #cf_span[0],表示该操作是 _pop()_;若等于 #cf_span[1],表示该操作是 _push(x)_。若操作为 _push(x)_,该行还包含一个整数 #cf_span[xi] (#cf_span[1 ≤ xi ≤ 106]) —— 被压入栈的整数。
保证整数 #cf_span[1] 到 #cf_span[m] 在所有 #cf_span[pi] 中恰好各出现一次。
请输出 #cf_span[m] 个整数。第 #cf_span[i] 个整数应等于在执行第 #cf_span[1] 到第 #cf_span[i] 步所回忆的所有操作后,栈顶的整数。如果此时栈为空,请输出 _-1_。
在第一个例子中,Nikita 在第一步回忆操作后,唯一执行的操作是 _push(2)_,因此答案是 #cf_span[2]。当他回忆起在 _push(2)_ 之前执行的 _pop()_ 操作后,答案保持不变。
在第二个例子中,操作为 _push(2)_、_push(3)_ 和 _pop()_。Nikita 按照它们实际执行的顺序回忆。
在第三个例子中,Nikita 按照相反的顺序回忆操作。
## Input
第一行包含整数 #cf_span[m] (#cf_span[1 ≤ m ≤ 105]) —— Nikita 执行的操作次数。接下来的 #cf_span[m] 行包含 Nikita 回忆的操作。第 #cf_span[i] 行以两个整数 #cf_span[pi] 和 #cf_span[ti] (#cf_span[1 ≤ pi ≤ m], #cf_span[ti = 0] 或 #cf_span[ti = 1]) 开头,分别表示他在第 #cf_span[i] 步回忆的操作的编号,以及操作类型。若 #cf_span[ti] 等于 #cf_span[0],表示该操作是 _pop()_;若等于 #cf_span[1],表示该操作是 _push(x)_。若操作为 _push(x)_,该行还包含一个整数 #cf_span[xi] (#cf_span[1 ≤ xi ≤ 106]) —— 被压入栈的整数。保证整数 #cf_span[1] 到 #cf_span[m] 在所有 #cf_span[pi] 中恰好各出现一次。
## Output
请输出 #cf_span[m] 个整数。第 #cf_span[i] 个整数应等于在执行第 #cf_span[1] 到第 #cf_span[i] 步所回忆的所有操作后,栈顶的整数。如果此时栈为空,请输出 _-1_。
[samples]
## Note
在第一个例子中,Nikita 在第一步回忆操作后,唯一执行的操作是 _push(2)_,因此答案是 #cf_span[2]。当他回忆起在 _push(2)_ 之前执行的 _pop()_ 操作后,答案保持不变。在第二个例子中,操作为 _push(2)_、_push(3)_ 和 _pop()_。Nikita 按照它们实际执行的顺序回忆。在第三个例子中,Nikita 按照相反的顺序回忆操作。
**Definitions**
Let $ m \in \mathbb{Z}^+ $ be the number of operations.
Let $ P = (p_1, p_2, \dots, p_m) $ be a permutation of $ \{1, 2, \dots, m\} $, where $ p_i $ is the original index of the operation remembered at step $ i $.
Let $ T = (t_1, t_2, \dots, t_m) $ be a sequence where $ t_i \in \{0, 1\} $ denotes the type of the operation remembered at step $ i $:
- $ t_i = 0 $: pop operation
- $ t_i = 1 $: push operation
For each $ i $ such that $ t_i = 1 $, let $ x_i \in \mathbb{Z}^+ $ be the integer pushed ($ 1 \le x_i \le 10^6 $).
Let $ O = (o_1, o_2, \dots, o_m) $ be the original sequence of operations, where $ o_j $ is the operation at original position $ j $, defined as:
- If $ t_i = 1 $ and $ p_i = j $, then $ o_j = \text{push}(x_i) $
- If $ t_i = 0 $ and $ p_i = j $, then $ o_j = \text{pop}() $
Let $ S_i $ be the state of the stack after performing all operations $ o_j $ for which $ p_k \le j $ for some $ k \le i $, in the order of increasing original index $ j $.
**Constraints**
1. $ 1 \le m \le 10^5 $
2. $ P $ is a permutation of $ \{1, 2, \dots, m\} $
3. $ t_i \in \{0, 1\} $ for all $ i \in \{1, \dots, m\} $
4. If $ t_i = 1 $, then $ 1 \le x_i \le 10^6 $
5. Each $ j \in \{1, \dots, m\} $ appears exactly once in $ P $
**Objective**
For each $ i \in \{1, \dots, m\} $, compute the top element of the stack after performing all operations $ o_j $ with $ j \in \{ p_1, p_2, \dots, p_i \} $, sorted by increasing $ j $, in the order of increasing $ j $.
If the stack is empty, output $ -1 $.
Output $ m $ integers: for each $ i = 1 $ to $ m $, output the top of the stack after step $ i $.