Your next assignment from CodeVax is to help develop a COVID-19 vaccine. To do this, you must decode COVID-19's genetic sequence. More specifically, COVID-19's gene sequence is represented by an by grid of numbers. To decode COVID-19's genome sequence you must rotate given subgrids in a very specific way. Thankfully, other scientists have already figured out the sequence of rotating subgrids and given you instructions on what to do. You must apply these instructions in the order they were given to the given subgrid to complete the vaccine.
Let and represent the top left and bottom right corner of a square subgrid, respectively. Instructions will come in the form:
r1 c1 r2 c2 x
: Rotate the square subgrid consisting of the points and clockwise by degrees.
Given the by grid of numbers and such instructions, please print out COVID-19's decoded genetic sequence.
Input Specification
The first line of input will contain a positive integer, .
The next lines will each contain positive integers.
The next line will contain a positive integer, .
The next lines will each contain the instructions on how to decode COVID-19's gene sequence.
Output Specification
Output COVID-19's genetic sequence after it has been decoded.
Constraints
For all subtasks:
Every number in the grid will be a value in the range .
It is guaranteed that is a multiple of and that .
Note that you will NOT be required to pass all the samples to receive points.
Subtask 1 [15%]
Subtask 2 [85%]
Sample Input 1
2
1 2
3 4
1
1 1 2 2 90
Sample Output 1
3 1
4 2
Sample Input 2
4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
5
1 1 4 4 360
2 2 3 3 -270
1 1 3 3 -90
2 2 4 4 180
3 2 4 3 90
Sample Output 2
3 6 7 4
2 16 15 14
1 8 12 5
13 11 9 10
Comments