#K35762. Bookshelf Order

    ID: 25604 Type: Default 1000ms 256MiB

Bookshelf Order

Bookshelf Order

In this problem, you are given a library with (m) shelves and (n) books per shelf. The books are arranged in a special pattern: the first shelf (i.e. row) contains books numbered from 1 to (n) in increasing order, the second shelf contains the next (n) books in decreasing order, the third shelf again in increasing order, and so on. Specifically, for the (i)-th row (0-indexed), if (i) is even, the books appear in increasing order; if (i) is odd, they appear in decreasing order. Your task is to output the arrangement of book IDs as they appear on each shelf.

inputFormat

The input consists of a single line containing two space-separated integers (m) and (n), where (m) represents the number of shelves (rows) and (n) represents the number of books per shelf.

outputFormat

Output exactly (m) lines. Each line should contain (n) space-separated integers representing the IDs of the books on that shelf in the order they appear.## sample

1 1
1

</p>