Codeforces Round 443 (Div. 1)
D
Magic Breeding
Codeforces
2900
原题
← CE →
翻译中…

Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have $*k*$ creatures numbered from $1$ to $*k*$. Creatures have $*n*$ different characteristics.

翻译中…

Sasha has a spell that allows to create a new creature from two given creatures. Each of its characteristics will be equal to the maximum of the corresponding characteristics of used creatures. Nikita has a similar spell, but in his spell, each characteristic of the new creature is equal to the minimum of the corresponding characteristics of used creatures. A new creature gets the smallest unused number.

翻译中…

They use their spells and are interested in some characteristics of their new creatures. Help them find out these characteristics.

翻译中…

Input

翻译中…

The first line contains integers $*n*$, $*k*$ and $*q*$ ($1 ≤ *n* ≤ 10^{5}$, $1 ≤ *k* ≤ 12$, $1 ≤ *q* ≤ 10^{5}$) — number of characteristics, creatures and queries.

翻译中…

Next $*k*$ lines describe original creatures. The line $*i*$ contains $*n*$ numbers $*a*_{*i*1}, *a*_{*i*2}, ..., *a*_{*in*}$ ($1 ≤ *a*_{*ij*} ≤ 10^{9}$) — characteristics of the $*i*$-th creature.

翻译中…

Each of the next $*q*$ lines contains a query. The $*i*$-th of these lines contains numbers $*t*_{*i*}$, $*x*_{*i*}$ and $*y*_{*i*}$ ($1 ≤ *t*_{*i*} ≤ 3$). They denote a query:

翻译中…
  • $*t*_{*i*} = 1$ means that Sasha used his spell to the creatures $*x*_{*i*}$ and $*y*_{*i*}$.
  • $*t*_{*i*} = 2$ means that Nikita used his spell to the creatures $*x*_{*i*}$ and $*y*_{*i*}$.
  • $*t*_{*i*} = 3$ means that they want to know the $*y*_{*i*}$-th characteristic of the $*x*_{*i*}$-th creature. In this case $1 ≤ *y*_{*i*} ≤ *n*$.
翻译中…

It's guaranteed that all creatures' numbers are valid, that means that they are created before any of the queries involving them.

翻译中…

Output

翻译中…

For each query with $*t*_{*i*} = 3$ output the corresponding characteristic.

翻译中…

Note

翻译中…

In the first sample, Sasha makes a creature with number $3$ and characteristics $(2, 2)$. Nikita makes a creature with number $4$ and characteristics $(1, 1)$. After that they find out the first characteristic for the creature $3$ and the second characteristic for the creature $4$.

翻译中…

样例

Input #1
2 2 4
1 2
2 1
1 1 2
2 1 2
3 3 1
3 4 2
Output #1
2
1
InputCopy OutputCopy
Input #2
5 3 8
1 2 3 4 5
5 1 2 3 4
4 5 1 2 3
1 1 2
1 2 3
2 4 5
3 6 1
3 6 2
3 6 3
3 6 4
3 6 5
Output #2
5
2
2
3
4
InputCopy OutputCopy
题目信息
题号
878D
时间限制
4 s
内存限制
1024 MB
标签
位运算

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。