~/algor $ cat problems/matritsa-ilonsimon-aylanish
Snake traversal
Easy
1000 ms
128 MB
33%
An integer matrix of size $n \times m$ is given. Print its elements on one line in snake order (odd rows left to right, even rows right to left).
Input
The first line contains two positive integers $n$ and $m$. Each of the next $n$ lines contains $m$ integers.
Output
One line with $n * m$ space-separated integers.
Note
$1 \le n, m \le 200$
$-1000 \le a_{i,j} \le 1000$
Examples
Input #1
3 3 1 2 3 4 5 6 7 8 9
Output #1
1 2 3 6 5 4 7 8 9
Input #2
2 1 4 -4
Output #2
4 -4