#C10944. Grid Rotation
Grid Rotation
Grid Rotation
You are given an n x n grid (matrix) of integers and an integer k. Your task is to rotate the grid by 90° clockwise, k times. Since rotating the grid 4 times returns it to its original state, you only need to apply k \mod 4 operations.
The mathematical operation for a single rotation can be described using LaTeX as follows:
[ new_grid[j][n-1-i] = grid[i][j] ]
Implement the grid rotation functionality such that the rotated grid is output to stdout.
inputFormat
The first line contains two integers n and k, where n is the number of rows (and columns) in the square grid, and k is the number of 90° clockwise rotations to perform. The following n lines each contain n space-separated integers representing the grid elements.
outputFormat
Output the rotated grid where each line contains n space-separated integers.
## sample3 1
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>