JOI-kun, an algorithm researcher, has developed a machine called the Bubble Sort Machine.
The Bubble Sort Machine operates on an integer sequence $a = (a_1, a_2, \dots , a_N)$ of length $N$. To activate the Bubble Sort Machine, the initial values $A_i$ are provided as input for each $a_i$ ($1 ≤ i ≤ N$). Each time Button 1 on the Bubble Sort Machine is pressed, the machine modifies the sequence $a$ in the following way:
To make the Bubble Sort Machine even more appealing, JOI-kun decided to add the following feature:
Given the initial values of the integer sequence and the sequence of operations on the Bubble Sort Machine, write a program that computes the outputs produced by Button 2.
Read the following data from the standard input.
$N$
$A_1$ $A_2$ $\cdots$ $A_N$
$Q$
(Query $1$)
(Query $2$)
$\vdots$
(Query $Q$)
Here, $Q$ is the number of operations performed on the Bubble Sort Machine. Each (Query $j$) ($1 ≤ j ≤ Q$) consists space separated integers. Let $T_j$ denote the first integer of (Query $j$). The content of this line is one of the following.
For each operation where Button 2 is pressed, that is, for each $j$ ($1 ≤ j ≤ Q$) such that $T_j = 2$, output the integer produced by the Bubble Sort Machine on a separate line in the order of the queries.