No difference multiple of four

Consider an n×mn \times m matrix of natural numbers. Here, we say that two numbers xx and yy of the matrix are neighbours if they are horizontally, vertically or diagonally adjacent. You have to add a number chosen among {2,3,5,8}\{2, 3, 5, 8\} to each number of the matrix. As a result, for every pair of neighbours xx and yy of the new matrix, xyx - y cannot be a multiple of four.

Input

Input consists of several cases, each one with nn and mm, both between 1 and 100, followed by nn lines, each one with mm integer numbers between 0 and 10910^9.

Output

For every given matrix, print your resulting matrix. If there is more than one solution, print any of them. Print a line with 20 dashes after every matrix.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:01:40.883Z

© Jutge.org, 2006–2026.
https://jutge.org