#C5104. Generate Sorted Matrix
Generate Sorted Matrix
Generate Sorted Matrix
You are given two integers n and m representing the number of rows and columns respectively. Your task is to generate an n × m matrix filled with consecutive integers from 1 to n*m such that every row and every column is sorted in increasing order.
More formally, let \(A_{i,j}\) denote the element in the i-th row and j-th column. Then, the value in each cell is given by:
\(A_{i,j} = (i-1) \times m + j\)
Print the generated matrix with each row in a new line, and elements within a row separated by a single space.
inputFormat
The input consists of a single line containing two space-separated integers n and m (1 ≤ n, m ≤ 100), where n is the number of rows and m is the number of columns of the matrix.
outputFormat
Output the matrix in n lines where each line contains m space-separated integers.
## sample3 3
1 2 3
4 5 6
7 8 9
</p>