Limits
1s, 512 MB
You are given two integers N and M.
You have to make a grid of N∗M size by following these rules:
- Each cell in the grid must have exactly one integer number.
- All numbers in the grid should be pairwise distinct. That means each number can't be repeated more than once.
- Let's say,GCD of all numbers in ith row is Ri where (1<=i<=N). All Ri should be pairwise distinct and Ri>1.
- Let's say,GCD of all numbers in jth column is Cj where (1<=j<=M). All Cj should be pairwise distinct and Cj>1.
- All numbers in the grid should be greater than 1 and less than 109.
It is guaranteed that under these constraints the answer always exists.
If there are multiple answers, you may print any of them.
Input
Input contains two integers N and M(1<=N,M<=1000).
Output
Output should contain N lines. For each line print M space separated integers. See sample output for more details.
Sample
Input | Output |
---|
2 3
| 3 6 12
48 24 16
|
In Sample Output: - Exactly one integer number in each cell of the grid.
- All numbers in the grid are pairwise distinct.
- GCD of all numbers in 1st row is 3, 2nd row is 8 which are greater than 1 and pairwise distinct.
- GCD of all numbers in 1st column is 3, 2nd column is 6, 3rd column is 4 which are greater than 1 and pairwise distinct.
- All numbers are greater than 1 and less than 109.
|
Factors
| CPU | Memory | Source |
---|
Bash 5.2 | 1× | 1× | 1× |
Brainf*ck | 1× | 1× | 1× |
C# Mono 6.0 | 1× | 1× | 1× |
C++17 GCC 13.2 | 1× | 1× | 1× |
C++20 Clang 16.0 | 1× | 1× | 1× |
C++20 GCC 13.2 | 1× | 1× | 1× |
C++23 GCC 13.2 | 1× | 1× | 1× |
C11 GCC 13.2 | 1× | 1× | 1× |
C17 GCC 13.2 | 1× | 1× | 1× |
C23 GCC 13.2 | 1× | 1× | 1× |
Common Lisp SBCL 2.0 | 1× | 1× | 1× |
D8 11.8 | 1× | 1× | 1× |
Erlang 22.3 | 1× | 1× | 1× |
Free Pascal 3.0 | 1× | 1× | 1× |
Go 1.22 | 1× | 1× | 1× |
Grep 3.7 | 1× | 1× | 1× |
Haskell 8.6 | 1× | 1× | 1× |
Java 1.8 | 1× | 1× | 1× |
Kotlin 1.1 | 1× | 1× | 1× |
Lua 5.4 | 1× | 1× | 1× |
Node.js 10.16 | 1× | 1× | 1× |
Perl 5.30 | 1× | 1× | 1× |
PHP 8.3 | 1× | 1× | 1× |
PyPy 7.1 (3.6) | 1× | 1× | 1× |
Python 3.12 | 1× | 1× | 1× |
Ruby 3.2 | 1× | 1× | 1× |
Rust 1.57 | 1× | 1× | 1× |
Swift 5.3 | 1× | 1× | 1× |
Whitespace | 1× | 1× | 1× |