#K64192. Grid Rotation Counter-Clockwise

    ID: 31921 Type: Default 1000ms 256MiB

Grid Rotation Counter-Clockwise

Grid Rotation Counter-Clockwise

You are given a grid consisting of R rows and C columns, where each element is a character. Your task is to rotate this grid 90° counter-clockwise. The rotated grid is obtained using the transformation:

rotated[i][j]=grid[j][C1i]rotated[i][j] = grid[j][C-1-i]

The input begins with an integer T, representing the number of test cases. For each test case, the first line contains two integers R and C, followed by R lines that represent the grid. For each test case, output the rotated grid with each row on a new line.

inputFormat

The first line contains an integer T, the number of test cases. Each test case starts with a line containing two space-separated integers R and C, denoting the number of rows and columns respectively. This is followed by R lines, each containing a string of length C representing a row of the grid.

outputFormat

For each test case, output the rotated grid. Each grid should be printed in the same order as described: each line represents one row of the rotated grid. All outputs are printed to standard output.## sample

1
3 3
abc
def
ghi
cfi

beh adg

</p>