#C2581. Rotate Matrix
Rotate Matrix
Rotate Matrix
You are given a matrix of integers and an integer k. Your task is to rotate the matrix 90° clockwise exactly k times and output the resulting matrix. Note that the matrix can be rectangular (i.e. non‐square) and that rotating a matrix four times will yield the original matrix.
The rotation operation transforms the matrix such that every element from position \(a_{i,j}\) moves to position \(a'_{j, m-1-i}\) after one 90° clockwise rotation.
Please read the input from standard input and print the result to standard output in the specified format.
inputFormat
The first line of input contains two integers \(m\) and \(n\), representing the number of rows and columns of the matrix respectively.
The next \(m\) lines each contain \(n\) space-separated integers representing each row of the matrix.
The following line contains an integer \(k\) which denotes the number of times the matrix should be rotated 90° clockwise. Note that \(k\) can be any non-negative integer.
outputFormat
Output the rotated matrix. Each row should be printed on a new line, with the elements separated by a single space.
## sample3 3
1 2 3
4 5 6
7 8 9
1
7 4 1
8 5 2
9 6 3
</p>