Read two non-zero natural numbers n and m and print a matrix with n rows and m columns filled with consecutive natural numbers starting from 1, in a snake pattern as shown in the example.
On rows with an even index (the first, the third, ...) the numbers increase from left to right. On rows with an odd index (the second, the fourth, ...) the numbers increase from right to left, continuing the count.