Print N M
Time limit1sMemory limit512 MB
Print the integers from 1 to N*M as N lines of M space-separated numbers each.
- Level
Easy1 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Problem
Given natural numbers N and M, print the numbers from 1 to N×M in the required format.
Input
The first line contains N and M separated by a single space. Both numbers are natural numbers less than or equal to 1,000.
Output
Print N lines in total. Each line must contain M integers separated by single spaces. Line 1 contains 1 through M, line 2 contains M+1 through 2×M, ..., and line N contains (N-1)×M+1 through N×M.
No line may begin or end with a space, and every line must end with a newline (\n).