Row Zigzag Matrix
Given two positive integers m and n, print an m x n matrix containing the numbers from 1 to m * n. Odd rows go left to right, even rows go right to left.
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 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
Comments