Rotate X12162


Statement
 

pdf   zip

To confuse his pursuers, Neo has invented a way to rotate the Matrix. However, Neo can only rotate the Matrix 90^\circ, 180^\circ, or 270^\circ. Help Neo compute a given rotation of the Matrix.

Input

The input consists of several test cases. Each test case starts with the number of rows 1n1001\leq n\leq 100 and the number of columns 1m1001\leq m\leq 100 of the Matrix, as well as the number of degrees dd that Neo wants to rotate the Matrix. This is followed by nn rows with mm integers each.

Output

For each test case, the matrix that results from rotating the Matrix dd degrees.

Public test cases
  • Input

    3 4 90
    9 1 2 4
    2 7 2 3
    7 5 1 3
    

    Output

    4 3 3
    2 2 1
    1 7 5
    9 2 7
    
  • Input

    4 2 0
    9 2
    4 7
    1 5
    3 8
    

    Output

    9 2
    4 7
    1 5
    3 8
    
  • Input

    3 3 180
    9 1 2
    6 2 7
    8 4 4
    

    Output

    4 4 8
    7 2 6
    2 1 9
    
  • Information
    Author
    Anders Jonsson
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++