#106Easy
Snake order
Time: 1 s · Memory: 256 MB
- Matrices
Statement
Print the elements of an matrix in a "snake": row 1 left to right, row 2 right to left, row 3 left to right again, and so on.
Input format
The first line contains and (). Each of the next lines contains integers ().
Output format
A single line with numbers.
Examples
Input
4 3 1 2 3 4 5 6 7 8 9 10 11 12
Output
1 2 3 6 5 4 7 8 9 12 11 10
Input
2 2 1 2 3 4
Output
1 2 4 3
Note
Choose the direction of the inner loop by the parity of the row number. In the first example: 1 2 3 6 5 4 7 8 9 12 11 10.
