In this problem, the mode of a sequence is the number that appears strictly more than half the times in the sequence. Please refer to this definition in the problem.
Initially, $n$ positive integer sequences of different lengths are given, numbered from $1$ to $n$, and the sequences can be empty. These $n$ sequences are considered to exist, and the sequences corresponding to other numbers are considered to be non-existent.
There are $q$ operations, and operations are of the following types:
-1 if the mode does not exist. The data guarantees that for any $1 \le i \le m$ the sequence numbered $x_i$ still exists, $1 \le x_i \le n + q$, and the concatenated sequence is non-empty. There is no guarantee that $x_i$ are distinct. The concatenation done here won't affect future operations.The first line of input contains two positive integers $n$ and $q$, which represent the number of initial sequences and the number of operations, respectively. It is guaranteed that $n, q \le 5 \times 10^5$.
In the next $n$ lines, the $i$-th line represents the sequence numbered $i$. The first non-negative integer $l_i$ of each line represents the length of the $i$-th sequence, followed by $l_i$ non-negative integers $a_{i,j}$ representing the elements of the sequence in order. Let $C_l = \Sigma l_i$ represent the sum of the input sequence lengths, then it is guaranteed that $C_l \le 5 \times 10^5$ and $a_{i,j} \le n + q$.
Each of the next $q$ lines represent an operation in the format described above, consisting of several integers. Let $C_m = \Sigma m$ represent the sum of all sequences that need to be concatenated in operation 3, then it is guaranteed that $C_m \leq 5 \times 10^{5}$.
For each type 3 query, output an integer on a new line, the answer to the query.
For all test data, it is guaranteed that $1 \le n, q, C_m, C_l \le 5 \times 10^{5}$.