Let $S_{-1}$ be an empty sequence. Process the following $Q$ queries. The $i$-th query is given in the following form.
0 $t_i$ $x_i$
: Define $S_i$ as the sequence obtained by adding $x_i$ to the end of $S_{t_i}$.1 $t_i$
: Define $S_i$ as the sequence obtained by deleting the front element of $S_{t_i}$. Print the deleted element.$S_{-1}$ を空の列とします。 $Q$ 個のクエリを処理してください。 $i$ 個目のクエリは以下の形式で与えられます。
0 $t_i$ $x_i$
: $S_{t_i}$ の末尾に $x_i$ を追加した列を $S_i$ とする。1 $t_i$
: $S_{t_i}$ の先頭を削除した列を $S_i$ とする。削除した要素を出力する。$Q$
$\textrm{Query}_0$
$\textrm{Query}_1$
:
$\textrm{Query}_{Q-1}$
6 0 -1 6 0 0 7 1 0 0 -1 8 1 3 1 1
6 8 6