P11244 Kiss of Autumn

Background

[English statement](https://www.luogu.com.cn/problem/U500140). **You must submit your code at the Chinese version of the statement.** After the autumn rain has just kissed the earth, white clouds roll up red, orange, yellow, green, cyan, blue, and purple. Wavelengths within the visible light range fall freely, giving the rising water vapor a gradually changing rhythm. The blurry impression of gradients is always hurried past by sunny days, but the often unusual range makes us remember it more clearly. So, is being ordered really optimal?

Description

Xiao C has $m$ integer sequences $a_1 \dots a_m$, and each sequence has length $n$. Xiao C wants to sort his sequences by integer value. So Xiao C has $q$ operations. In each operation: - Either, Xiao C gives $x, y\ (x \neq y)$. He wants to concatenate $a_x$ and $a_y$ into a sequence $b$ of length $2n$. After sorting $b$ in nondecreasing order, take $b_1 \dots b_n$ as the new $a_x$, and take $b_{n+1} \dots b_{2n}$ as the new $a_y$. - Or, Xiao C gives $i, j$. Careful Xiao C wants to ask you: after the previous operations, what is the value of $a_{i,j}$? You need to answer his question exactly.

Input Format

The first line contains three integers $n, m, q$. The next $m$ lines each contain $n$ integers. The $j$-th integer on the $i$-th line denotes $a_{i,j}$. The next $q$ lines each contain three integers, describing one operation or one query, in one of the following two formats: - $\verb!1 x y!$ means sorting $a_x$ and $a_y$, where $1 \leq x \neq y \leq m$. - $\verb!2 i j!$ means querying $a_{i,j}$, where $1 \leq i \leq m$ and $1 \leq j \leq n$.

Output Format

For each query, output one integer per line, representing the answer.

Explanation/Hint

### Constraints **This problem uses bundled test and subtask dependencies.** Because the maximum input sizes of the last two subtasks reach $18\text{MB}$ and more than $50\text{MB}$ respectively, C++ users may choose to use the following **fast I/O template**: ```cpp namespace FastIO { char buf[1