cho.sh
Notes
Loading...

Number Grid Filling

Time limit

1s

Memory limit

128 MB

Problem

Fill an N x M grid with integers. Two cells are adjacent if they share an edge.

If you take the absolute differences between all adjacent pairs, the integers from 1 through 2NM - N - M must each appear exactly once.

Given N and M, output any grid that satisfies the condition.

Input

The first line contains two integers N and M. (1 <= N, M <= 1,000)

Output

Print the grid in N lines. Each line must contain M integers separated by spaces.

If there are multiple valid answers, print any one of them. Every cell value must be an integer from 1 through 2 x 10^9.