14786 - Rotating Potato   

Description

Potato wants to go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrotating. He's got a grid of numbers, and wanted to rotate it clockwise multiple times.

So, as a lovely kind student, you must be happy to write a program that quickly help him get the final result.

Potato judges your code by the following limitations:

  • Testcase 1:
    n = m = 2, 0 < k < 4
  • Testcase 2 ~ 3:
    0 < n = m < 9, 0 < k < 4
  • Testcase 4 ~ 5:
    0 < n,m < 1000 < k
  • Testcase 6:
    0 < n,m0 < k

Input

The first line contains 3 integer n,m,k, representing the grid's size if nxm, and Potato's gonna rotate it clockwise by k times.

Following by n lines, each containing m integers, forming the grid.

Output

Output the final grid after the k-th rotation.

Sample Input  Download

Sample Output  Download

Tags




Discuss