CF641B.Little Artem and Matrix

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.

That element can store information about the matrix of integers size n×mn×m . There are n+mn+m inputs in that element, i.e. each row and each column can get the signal. When signal comes to the input corresponding to some row, this row cyclically shifts to the left, that is the first element of the row becomes last element, second element becomes first and so on. When signal comes to the input corresponding to some column, that column shifts cyclically to the top, that is first element of the column becomes last element, second element becomes first and so on. Rows are numbered with integers from 11 to nn from top to bottom, while columns are numbered with integers from 11 to mm from left to right.

Artem wants to carefully study this element before using it. For that purpose he is going to set up an experiment consisting of qq turns. On each turn he either sends the signal to some input or checks what number is stored at some position of the matrix.

Artem has completed his experiment and has written down the results, but he has lost the chip! Help Artem find any initial matrix that will match the experiment results. It is guaranteed that experiment data is consistent, which means at least one valid matrix exists.

输入格式

The first line of the input contains three integers nn , mm and qq ( 1<=n,m<=100,1<=q<=100001<=n,m<=100,1<=q<=10000 ) — dimensions of the matrix and the number of turns in the experiment, respectively.

Next qq lines contain turns descriptions, one per line. Each description starts with an integer tit_{i} ( 1<=ti<=31<=t_{i}<=3 ) that defines the type of the operation. For the operation of first and second type integer rir_{i} ( 1<=ri<=n1<=r_{i}<=n ) or cic_{i} ( 1<=ci<=m1<=c_{i}<=m ) follows, while for the operations of the third type three integers rir_{i} , cic_{i} and xix_{i} ( 1<=ri<=n1<=r_{i}<=n , 1<=ci<=m1<=c_{i}<=m , 109<=xi<=109-10^{9}<=x_{i}<=10^{9} ) are given.

Operation of the first type ( ti=1t_{i}=1 ) means that signal comes to the input corresponding to row rir_{i} , that is it will shift cyclically. Operation of the second type ( ti=2t_{i}=2 ) means that column cic_{i} will shift cyclically. Finally, operation of the third type means that at this moment of time cell located in the row rir_{i} and column cic_{i} stores value xix_{i} .

输出格式

Print the description of any valid initial matrix as nn lines containing mm integers each. All output integers should not exceed 10910^{9} by their absolute value.

If there are multiple valid solutions, output any of them.

输入输出样例

  • 输入#1

    2 2 6
    2 1
    2 2
    3 1 1 1
    3 2 2 2
    3 1 2 8
    3 2 1 8
    

    输出#1

    8 2 
    1 8 
    
  • 输入#2

    3 3 2
    1 2
    3 2 2 5
    

    输出#2

    0 0 0 
    0 0 5 
    0 0 0 
    
首页