


The first line of input contains an integer 'T' representing the number of the test cases. Then ‘T' test cases follow.
The first line of each test case contains two space-separated integers, 'N', 'M', the dimensions of the 2D array.
The next ‘N’ lines consist of ‘M’ space-separated integers denoting the array elements.
For each test case, return a 1D array storing the input array elements like a wave.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= ‘T’ <= 10
1 <= 'N', ‘M’ <= 10^3
1 <= ‘ARR[i][j]’ <= 10^5
Where ARR[i][j] is the array element in the ith row of the jth column.
Time limit: 1 second
We can observe that considering 1 based indexing, the rows having odd index need to be read from left to right, and the rows having index even are read from right to left. Therefore for all the rows we can check this condition and insert the elements in a linear array ANS.
Return the array ANS.