atcoder#AGC027D. [AGC027D] Modulo Matrix

[AGC027D] Modulo Matrix

Score : 11001100 points

Problem Statement

You are given an integer NN.

Construct any one NN-by-NN matrix aa that satisfies the conditions below. It can be proved that a solution always exists under the constraints of this problem.

  • 1ai,j10151 \leq a_{i,j} \leq 10^{15}
  • ai,ja_{i,j} are pairwise distinct integers.
  • There exists a positive integer mm such that the following holds: Let xx and yy be two elements of the matrix that are vertically or horizontally adjacent. Then, max(x,y){\rm max}(x,y) mod{\rm mod} min(x,y){\rm min}(x,y) is always mm.

Constraints

  • 2N5002 \leq N \leq 500

Input

Input is given from Standard Input in the following format:

NN

Output

Print your solution in the following format:

a1,1a_{1,1} ...... a1,Na_{1,N}

::

aN,1a_{N,1} ...... aN,Na_{N,N}

2
4 7
23 10
  • For any two elements xx and yy that are vertically or horizontally adjacent, max(x,y){\rm max}(x,y) mod{\rm mod} min(x,y){\rm min}(x,y) is always 33.