Problem title
Difficulty
Avg time to solve

Ninja And Editor
Easy
20 mins
Encoded Letter
Moderate
25 mins
Tree Jumping
Hard
50 mins
Base Conversion
Easy
15 mins
Number of ones in the smallest repunit
Moderate
30 mins
Conversion
Easy
20 mins
Moderate
15 mins
Last Substring In Lexicographical Order
Hard
45 mins
Minimum And Maximum
Easy
15 mins
Rectangles In N x N Board
Moderate
20 mins

# Ninja And Matrix

Difficulty: EASY
Avg. time to solve
15 min
Success Rate
85%

Problem Statement

#### Ninja loves patterns and visuals and recently he learned about 2-dimensional matrices now he wants to use his pattern skills on it. He has been provided with a 2-dimensional matrix with a size of ‘N’x’N’ and he wants to print the matrix in a snake pattern. Formally speaking he wants to print every odd indexed row in reverse order(0-indexed) and even indexed row as it is on a single line.

##### EXAMPLE:
``````Input: 'N' = 2, ‘MAT’ = [[1, 2], [5, 6]]

Output: 1 2 6 5

So the first row will be printed as it is and the second row will be printed in reverse order.
``````
##### Input Format :
``````The first line will contain the integer 'T', denoting the number of test cases.

For each test case, the first line will contain a single integer 'N', the size of the matrix ‘Mat’, and then the next ‘N’ lines will contain ‘N’ integers representing the matrix elements.
``````
##### Output format :
``````For each test case, print the matrix in a specified manner on a new line.
``````
##### Note :
``````You don't need to print anything. It has already been taken care of. Just implement the given function.
``````
##### Constraints :
``````1 <= 'T' <= 10
1 <= 'N' <= 10^3
1 <= ‘MAT[i]’ <= 10^9

Time Limit: 1 sec
``````
##### Sample Input 1 :
``````2
3
1 2 3
4 5 6
7 8 9
2
5 10
20 15
``````
##### Sample Output 1 :
``````1 2 3 6 5 4 7 8 9
5 10 15 20
``````
##### Explanation Of Sample Input 1 :
``````For the first case:
The first row will be printed as it is and the second row will be printed in reverse order.

For the second case:
Similarly as for test 1.
``````
##### Sample Input 2 :
``````2
1
1
2
4 4
6 6
``````
##### Sample Output 2 :
``````1
4 4 6 6
``````   Console