CF878D.Magic Breeding

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have kk creatures numbered from 11 to kk . Creatures have nn 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.

输入格式

The first line contains integers nn , kk and qq ( 1<=n<=1051<=n<=10^{5} , 1<=k<=121<=k<=12 , 1<=q<=1051<=q<=10^{5} ) — number of characteristics, creatures and queries.

Next kk lines describe original creatures. The line ii contains nn numbers ai1,ai2,...,aina_{i1},a_{i2},...,a_{in} ( 1<=aij<=1091<=a_{ij}<=10^{9} ) — characteristics of the ii -th creature.

Each of the next qq lines contains a query. The ii -th of these lines contains numbers tit_{i} , xix_{i} and yiy_{i} ( 1<=ti<=31<=t_{i}<=3 ). They denote a query:

  • ti=1t_{i}=1 means that Sasha used his spell to the creatures xix_{i} and yiy_{i} .
  • ti=2t_{i}=2 means that Nikita used his spell to the creatures xix_{i} and yiy_{i} .
  • ti=3t_{i}=3 means that they want to know the yiy_{i} -th characteristic of the xix_{i} -th creature. In this case 1<=yi<=n1<=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.

输出格式

For each query with ti=3t_{i}=3 output the corresponding characteristic.

输入输出样例

  • 输入#1

    2 2 4
    1 2
    2 1
    1 1 2
    2 1 2
    3 3 1
    3 4 2
    

    输出#1

    2
    1
    
  • 输入#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
    

    输出#2

    5
    2
    2
    3
    4
    

说明/提示

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

首页