{"raw_statement":[{"iden":"statement","content":"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.\n\nNikita 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!"},{"iden":"input","content":"The first line contains the integer _m_ (1 ≤ _m_ ≤ 105) — the number of operations Nikita made.\n\nThe 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.\n\nIt is guaranteed that each integer from 1 to _m_ is present exactly once among integers _p__i_."},{"iden":"output","content":"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_."},{"iden":"examples","content":"Input\n\n2\n2 1 2\n1 0\n\nOutput\n\n2\n2\n\nInput\n\n3\n1 1 2\n2 1 3\n3 0\n\nOutput\n\n2\n3\n2\n\nInput\n\n5\n5 0\n4 0\n3 1 1\n2 1 1\n1 1 2\n\nOutput\n\n\\-1\n-1\n-1\n-1\n2"},{"iden":"note","content":"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.\n\nIn the second example, the operations are _push(2)_, _push(3)_ and _pop()_. Nikita remembers them in the order they were performed.\n\nIn the third example Nikita remembers the operations in the reversed order."}],"translated_statement":[{"iden":"statement","content":"Nikita 有一个栈。在本题中，栈是一种支持两种操作的数据结构：操作 _push(x)_ 将整数 #cf_span[x] 放到栈顶，操作 _pop()_ 删除栈顶的整数，即最后添加的那个。如果栈为空，则 _pop()_ 操作不产生任何效果。\n\nNikita 对栈进行了 #cf_span[m] 次操作，但他忘记了这些操作。现在他想回忆起来。他逐个回忆，第 #cf_span[i] 步时，他回忆起第 #cf_span[pi] 次操作。换句话说，他按照某个排列 #cf_span[p1, p2, ..., pm] 的顺序回忆操作。在每一步之后，Nikita 想知道：在按对应顺序执行他已经回忆起的所有操作后，栈顶的整数是多少？请帮助他！\n\n第一行包含整数 #cf_span[m] (#cf_span[1 ≤ m ≤ 10^5]) —— Nikita 执行的操作次数。\n\n接下来的 #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 ≤ 10^6]) —— 被压入栈的整数。\n\n保证整数 #cf_span[1] 到 #cf_span[m] 在 #cf_span[pi] 中各出现恰好一次。\n\n请输出 #cf_span[m] 个整数。第 #cf_span[i] 个整数应等于在执行第 #cf_span[1] 到第 #cf_span[i] 步所回忆的所有操作后，栈顶的数字。如果此时栈为空，请输出 _-1_。\n\n在第一个例子中，Nikita 在第一步回忆操作后，唯一执行的操作是 _push(2)_，因此答案是 #cf_span[2]。当他回忆起在 _push(2)_ 之前执行的 _pop()_ 操作后，答案保持不变。\n\n在第二个例子中，操作是 _push(2)_、_push(3)_ 和 _pop()_。Nikita 按照它们被执行的顺序回忆。\n\n在第三个例子中，Nikita 按照相反的顺序回忆操作。"},{"iden":"input","content":"第一行包含整数 #cf_span[m] (#cf_span[1 ≤ m ≤ 10^5]) —— 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 ≤ 10^6]) —— 被压入栈的整数。保证整数 #cf_span[1] 到 #cf_span[m] 在 #cf_span[pi] 中各出现恰好一次。"},{"iden":"output","content":"请输出 #cf_span[m] 个整数。第 #cf_span[i] 个整数应等于在执行第 #cf_span[1] 到第 #cf_span[i] 步所回忆的所有操作后，栈顶的数字。如果此时栈为空，请输出 _-1_。"},{"iden":"examples","content":"输入22 1 21 0输出22输入31 1 22 1 33 0输出232输入55 04 03 1 12 1 11 1 2输出-1-1-1-12"},{"iden":"note","content":"在第一个例子中，Nikita 在第一步回忆操作后，唯一执行的操作是 _push(2)_，因此答案是 #cf_span[2]。当他回忆起在 _push(2)_ 之前执行的 _pop()_ 操作后，答案保持不变。在第二个例子中，操作是 _push(2)_、_push(3)_ 和 _pop()_。Nikita 按照它们被执行的顺序回忆。在第三个例子中，Nikita 按照相反的顺序回忆操作。"}],"sample_group":[],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}