DMOPC '23 Contest 1 P1 - Peak Grid
View as PDFAschin is interested in the peaks of a grid. A peak is defined as an element of the grid that is the largest in both the row and column containing that element. Please impress Aschin by constructing an  by 
 grid of distinct integers from 
 to 
 such that it has exactly 
 peaks.
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specification
The first and only line contains the space-separated integers  and 
.
Output Specification
Output  lines containing 
 space-separated integers, a grid of size 
 by 
 which contains each integer from 
 to 
 such that there are exactly 
 peaks. If there are multiple solutions, output any of them. If such a grid does not exist, output 
.
Sample Input
3 2
Sample Output
9 1 2
8 7 5
4 3 6
Explanation for Sample
 and 
 are the 
 peaks.
Comments