Column Zigzag Matrix
Given two positive integers m and n, print an m x n matrix containing the numbers from 1 to m * n. Odd columns go top to bottom, even columns go bottom to top.
Input
- One line containing two positive integers m and n.
Output
- Numbers on the same line are separated by exactly one space.
Constraints
- 1 <= m, n <= 50
Example
Input
4 5
Output
1 8 9 16 17
2 7 10 15 18
3 6 11 14 19
4 5 12 13 20
Comments