#P1485D. Multiples and Power Differences
Multiples and Power Differences
No submission language available for this problem.
Description
You are given a matrix consisting of positive integers. It has rows and columns.
Construct a matrix consisting of positive integers. It should have the same size as , and the following conditions should be met:
- ;
- is a multiple of ;
- the absolute value of the difference between numbers in any adjacent pair of cells (two cells that share the same side) in is equal to for some integer ( is not necessarily the same for all pairs, it is own for each pair).
We can show that the answer always exists.
The first line contains two integers and ().
Each of the following lines contains integers. The -th integer in the -th line is ().
The output should contain lines each containing integers. The -th integer in the -th line should be .
Input
The first line contains two integers and ().
Each of the following lines contains integers. The -th integer in the -th line is ().
Output
The output should contain lines each containing integers. The -th integer in the -th line should be .
Samples
Note
In the first example, the matrix can be used as the matrix , because the absolute value of the difference between numbers in any adjacent pair of cells is .
In the third example:
- is a multiple of , is a multiple of , is a multiple of , is a multiple of ;
- , , , .