Problems
After receiving the height n and width m of the rectangle,
write a program that prints numbers from 1 to n × m in order inside the rectangle in a zigzag pattern.
<Processing Conditions>
The order of the numbers proceeds as follows: first, move from left to right for a width of m, then change direction and repeat this pattern.

Input
Receive the height n and width m of the rectangle (n and m are integers not exceeding 100).
Output
Print the rectangular shape described above according to the height n and width m given in the input.
Separate the numbers with spaces.
Example
4 5
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
Tag
Source
JUNGOL