Limits 1s, 512 MB

You are given two integers NN and MM.

You have to make a grid of NMN* M size by following these rules:

  1. Each cell in the grid must have exactly one integer number.
  2. All numbers in the grid should be pairwise distinct. That means each number can't be repeated more than once.
  3. Let's say,GCD of all numbers in iith row is RiRi where (1<=i<=N)(1<=i<=N). All RiRi should be pairwise distinct and Ri>1Ri > 1.
  4. Let's say,GCD of all numbers in jjth column is CjCj where (1<=j<=M)(1<=j<=M). All CjCj should be pairwise distinct and Cj>1Cj > 1.
  5. All numbers in the grid should be greater than 11 and less than 10910^9.

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 NN and M(1<=N,M<=1000).M (1<=N,M<=1000).

Output

Output should contain NN lines. For each line print MM space separated integers. See sample output for more details.

Sample

InputOutput
2 3
3 6 12
48 24 16

In Sample Output:

  1. Exactly one integer number in each cell of the grid.
  2. All numbers in the grid are pairwise distinct.
  3. GCD of all numbers in 1st row is 3, 2nd row is 8 which are greater than 1 and pairwise distinct.
  4. 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.
  5. All numbers are greater than 1 and less than 10910^9.

Submit

Login to submit.

Contributors

Statistics

70% Solution Ratio
Tanveer2202Earliest, Aug '21
steinumFastest, 0.0s
steinumLightest, 5.5 kB
steinumShortest, 433B
Toph uses cookies. By continuing you agree to our Cookie Policy.