Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-ustunma-ustun-raqamlash

Column-wise numbering

Easy 1000 ms 64 MB 20%
Share

Fill a table of $n$ rows and $m$ columns with the numbers from $1$ to $n \cdot m$ column by column: the first column top to bottom gets $1, 2, \dots, n$, the second $n + 1, \dots, 2n$, and so on. Print the table.

A 3 by 4 table: numbers go down each column, then move on to the next column

Input

One line with two positive integers: $n$ and $m$.

Output

$n$ lines with $m$ numbers each.

Note

$1 \le n, m \le 100$

Examples

Input #1
3 4
Output #1
1 4 7 10
2 5 8 11
3 6 9 12
Input #2
1 1
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.