Given a** **square** **matrix **mat[][]** of size **N x N**. The task is to rotate it by** 90 degrees in anti-clockwise** direction without using any extra space.

**Input:**

The first line of input contains a single integer **T** denoting the number of test cases. Then** **T test cases follow. Each test case consist of two lines. The first line of each test case consists of an integer **N**, where **N** is the size of the square matrix.The second line of each test case contains **N x N** space separated values of the matrix **mat**.

**Output:**

Corresponding to each test case, in a new line, print the rotated array.

**Constraints:**

1 ≤ T ≤ 50

1 ≤ N ≤ 50

1 <= mat[][] <= 100

**Example:**

**Input**:

1

3

1 2 3 4 5 6 7 8 9

**Output**:

3 6 9 2 5 8 1 4 7

**Explanation:
Testcase 1:** Matrix is as below:

1 2 3

4 5 6

7 8 9

Rotating it by 90 degrees in anticlockwise directions will result as below matrix:

3 6 9

2 5 8

1 4 7

lakshmi_pandey | 72 |

abbatta7 | 68 |

Ashish Kumar Vaishy | 62 |

aman19 | 58 |

Kumar Gaurav Singh | 58 |

saumitra13325 | 612 |

ashujack | 551 |

lakshmi_pandey | 544 |

aman19 | 538 |

piyushmittal25 | 514 |

blackshadows | 5249 |

akhayrutdinov | 5111 |

Ibrahim Nash | 5087 |

Quandray | 4354 |

sanjay05 | 3668 |

Login to report an issue on this page.