You are given a matrix a consisting of positive integers. It has n rows and m columns.

Construct a matrix b consisting of positive integers. It should have the same size as a, and the following conditions should be met: 

  * 1 ≤ b_{i,j} ≤ 10^6; 
  * b_{i,j} is a multiple of a_{i,j}; 
  * the absolute value of the difference between numbers in any adjacent pair of cells (two cells that share the same side) in b is equal to k^4 for some integer k ≥ 1 (k is not necessarily the same for all pairs, it is own for each pair). 



We can show that the answer always exists.

Input

The first line contains two integers n and m (2 ≤ n,m ≤ 500).

Each of the following n lines contains m integers. The j-th integer in the i-th line is a_{i,j} (1 ≤ a_{i,j} ≤ 16).

Output

The output should contain n lines each containing m integers. The j-th integer in the i-th line should be b_{i,j}.

Examples

Input


2 2
1 2
2 3


Output


1 2
2 3


Input


2 3
16 16 16
16 16 16


Output


16 32 48
32 48 64


Input


2 2
3 11
12 8


Output


327 583
408 664

Note

In the first example, the matrix a can be used as the matrix b, because the absolute value of the difference between numbers in any adjacent pair of cells is 1 = 1^4.

In the third example: 

  * 327 is a multiple of 3, 583 is a multiple of 11, 408 is a multiple of 12, 664 is a multiple of 8; 
  * |408 - 327| = 3^4, |583 - 327| = 4^4, |664 - 408| = 4^4, |664 - 583| = 3^4.

Difficulty: HARD
Tags: Number theory

Graph algorithms

Mathematics

Constructive algorithms

Starter code:

Solutions:
(n, m) = list(map(int, input().split()))
matrix = []
for i in range(n):
	row = list(map(int, input().split()))
	matrix.append(row)
res = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			res[i][j] = 720720 + matrix[i][j] ** 4
		else:
			res[i][j] = 720720
		print(res[i][j], end=' ')
	print()


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(m):
		a[i][j] = 720720 + (i + j) % 2 * pow(a[i][j], 4)
for i in a:
	print(*i)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
ans = [[] for i in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			ans[i].append(720720)
		else:
			ans[i].append(720720 + l[i][j] ** 4)
for i in range(n):
	print(*ans[i])


import collections
import string
import math
import copy
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
mo = 998244353

def exgcd(a, b):
	if not b:
		return (1, 0)
	(y, x) = exgcd(b, a % b)
	y -= a // b * x
	return (x, y)

def getinv(a, m):
	(x, y) = exgcd(a, m)
	return --1 if x == 1 else x % m

def comb(n, b):
	res = 1
	b = min(b, n - b)
	for i in range(b):
		res = res * (n - i) * getinv(i + 1, mo) % mo
	return res % mo

def quickpower(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % mo
		n >>= 1
		a = a * a % mo
	return res

def dis(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])

def getpref(x):
	if x > 1:
		return x * (x - 1) >> 1
	else:
		return 0

def orafli(upp):
	primes = []
	marked = [False for i in range(upp + 3)]
	for i in range(2, upp):
		if not marked[i]:
			primes.append(i)
		for j in primes:
			if i * j >= upp:
				break
			marked[i * j] = True
			if i % j == 0:
				break
	return primes
history = {}
askctr = 0

def ask(s):
	global askctr, history
	if s in history:
		return history[s]
	askctr += 1
	print(f'? {s}', flush=True)
	ret = int(input())
	hisadd(s, ret)
	chkans(s)
	return ret

def answer(s):
	print(f'! {s}', flush=True)

def getans(history, l, r):
	for i in range(l, r + 1):
		ask(i)
		history[i] = int(input())
		if i == 2:
			if 1 in history:
				if history[2] > history[1]:
					answer(1)
					return
		elif i - 1 in history and i - 2 in history:
			if history[i - 1] < history[i - 2] and history[i - 1] < history[i]:
				answer(i - 1)
				return

def chkans(i):
	global history, n
	if i == 1:
		if history.get(2, 0) > history.get(1, 999999999):
			answer(1)
			exit(0)
			return True
	elif i == n:
		if history.get(n - 1, 0) > history.get(n, 999999999):
			answer(n)
			exit(0)
			return True
	elif history.get(i - 1, 0) > history.get(i, 99999999) < history.get(i + 1, 0):
		if 0 < i <= n:
			answer(i)
			exit(0)
			return True
	return False

def hisadd(pos, val):
	global history
	if val == 1:
		answer(pos)
		exit(0)
		return True
	else:
		history[pos] = val
		return chkans(pos)

def solve():
	(A, B) = map(int, input().split())
	tot = 0
	p = B - 1 - (A - 2)
	i = 1
	while 1:
		d = min(A // i - 1 - i, B - i)
		if d > 0:
			tot += d
		else:
			break
		i += 1
	print(tot)
mmp = []
for i in range(0, 17):
	mmp.append(i ** 4)
(n, m) = map(int, input().split())
ma = []
for i in range(n):
	l = [int(i) for i in input().split()]
	ma.append(l)
mp = [[720720 for j in range(m)] for i in range(n)]
for i in range(n):
	for j in range(m):
		if (i ^ j) & 1:
			mp[i][j] -= mmp[ma[i][j]]
for i in mp:
	print(*i)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, m) = invr()
a = [[] for i in range(n)]
for i in range(n):
	a[i] = inara()
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			a[i][j] = 720720
		else:
			a[i][j] = 720720 + a[i][j] * a[i][j] * a[i][j] * a[i][j]
for i in range(n):
	print(*a[i])


c = [720720, 720719, 720704, 720639, 720704, 720095, 719424, 718319, 720704, 720639, 710720, 706079, 719424, 692159, 682304, 670095, 720704]
(n, m) = map(int, input().split())
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(m):
		if (i + j) % 2 == 0:
			print(c[0])
		else:
			print(c[a[j]])


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def def_value():
	return 0
(n, m) = mp()
for i in range(n):
	b = lmp()
	for j in range(m):
		if (i + j) % 2 == 0:
			b[j] = 720720
		else:
			b[j] = 720720 - b[j] ** 4
	print(*b)


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	(n, m) = map(int, input().split())
	lcm = 1
	for j in range(2, 17):
		p = lcm * j
		g = math.gcd(lcm, j)
		lcm = p // g
	for j in range(n):
		a = list(map(int, input().split()))
		for k in range(m):
			if (j + k) % 2 == 0:
				print(lcm, end=' ')
			else:
				print(lcm + a[k] ** 4, end=' ')
		print()


from sys import stdin, stdout
from collections import defaultdict
import math

def main():
	(n, m) = list(map(int, stdin.readline().split()))
	arr = []
	for i in range(n):
		arr.append(list(map(int, stdin.readline().split())))
	lcm = 1
	for i in range(1, 17):
		lcm = i * lcm // math.gcd(i, lcm)
	for i in range(n):
		ans = []
		for j in range(m):
			if (i + j) % 2 == 1:
				ans.append(lcm + arr[i][j] ** 4)
			else:
				ans.append(lcm)
		stdout.write(' '.join((str(x) for x in ans)) + '\n')
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 10 ** 9 + 7
from copy import deepcopy
pow4 = set([i ** 4 for i in range(1, 32)])

def solve():
	(N, M) = getInts()
	A = getMat(N)
	B = deepcopy(A)
	for i in range(N):
		for j in range(M):
			if (i + j) % 2 == 0:
				B[i][j] = 720720
			else:
				B[i][j] = 720720 + A[i][j] ** 4
	for b in B:
		print(*b)
	return
solve()


(n, m) = map(int, input().split())
mat = []
for i in range(n):
	mat.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			print(720720, end=' ')
		else:
			print(720720 + pow(mat[i][j], 4), end=' ')
	print()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def S():
	return input().strip()

def print_list(l):
	print(' '.join(map(str, l)))
p = [i ** 4 for i in range(17)]
(n, m) = RL()
for i in range(n):
	a = RLL()
	for j in range(m):
		if i + j & 1:
			a[j] = 720720
		else:
			a[j] = 720720 + p[a[j]]
	print_list(a)


import sys
input = sys.stdin.readline
from sys import stdin, stdout
from collections import defaultdict, Counter
from math import gcd
M = 10 ** 9 + 7
lcm = lambda a, b: a * b // gcd(a, b)

def main():
	(n, m) = [int(s) for s in input().split()]
	l = [[int(s) for s in input().split()] for i in range(n)]
	x = 1
	s = set()
	for i in range(n):
		for j in range(m):
			if l[i][j] not in s:
				s.add(l[i][j])
				x = lcm(x, l[i][j])
	for i in range(n):
		for j in range(m):
			if i % 2:
				if j % 2:
					print(x, end=' ')
				else:
					print(x + l[i][j] ** 4, end=' ')
			elif j % 2 == 0:
				print(x, end=' ')
			else:
				print(x + l[i][j] ** 4, end=' ')
		print()
main()


p = lambda : map(int, input().split())
(N, M) = p()
for i in range(N):
	print(*[720720 + a ** 4 * (1 - (i ^ j) & 1) for (j, a) in enumerate(list(p()))])


(N, M) = map(int, input().split())
for i in range(N):
	print(*[720720 + (a ** 4 if (i ^ j) & 1 else 0) for (j, a) in enumerate([int(a) for a in input().split()])])


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_(mrr):
	magic = 2 ** 4 * 3 ** 2 * 5 * 7 * 11 * 13
	log(magic)
	mrr = [[magic + x ** 4 if (i - j) % 2 else magic for (i, x) in enumerate(row)] for (j, row) in enumerate(mrr)]
	return mrr
for case_num in [0]:
	(a, b) = list(map(int, input().split()))
	mrr = read_matrix(a)
	res = solve(mrr)
	for r in res:
		print(*r)


(n, m) = map(int, input().split())
A = []
B = []
for i in range(n):
	A.append(list(map(int, input().split())))
	B.append([0] * m)
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			B[i][j] = 720720
		elif A[i][j] == 1:
			B[i][j] = 2 * 2 * 2 * 2 * 2 * 2 * 11261
		elif A[i][j] == 2:
			B[i][j] = 2 * 2 * 2 * 2 * 2 * 2 * 11261
		elif A[i][j] == 3:
			B[i][j] = 2 * 2 * 2 * 2 * 2 * 2 * 3 * 3 * 1249
		elif A[i][j] == 4:
			B[i][j] = 2 * 2 * 2 * 2 * 2 * 2 * 11261
		elif A[i][j] == 5:
			B[i][j] = 710720
		elif A[i][j] == 6:
			B[i][j] = 699984
		elif A[i][j] == 7:
			B[i][j] = 106064
		elif A[i][j] == 8:
			B[i][j] = 2 * 2 * 2 * 2 * 2 * 2 * 11261
		elif A[i][j] == 9:
			B[i][j] = 388944
		elif A[i][j] == 10:
			B[i][j] = 710720
		elif A[i][j] == 11:
			B[i][j] = 706079
		elif A[i][j] == 12:
			B[i][j] = 719424
		elif A[i][j] == 13:
			B[i][j] = 263744
		elif A[i][j] == 14:
			B[i][j] = 106064
		elif A[i][j] == 15:
			B[i][j] = 670095
		elif A[i][j] == 16:
			B[i][j] = 682304
for i in range(len(B)):
	print(*B[i])


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		mat.append(list(map(int, input().split())))
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				print(720720, end=' ')
			else:
				print(720720 + pow(mat[i][j], 4), end=' ')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def input_as_list():
	return [int(t) for t in input().split()]
C = 720720
(n, m) = input_as_list()
g = [input_as_list() for _ in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			g[i][j] = C
		else:
			g[i][j] = C + g[i][j] ** 4
for row in g:
	print(*row)


(n, m) = map(int, input().split())
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(m):
		if j + i & 1:
			print(720720, end=' ')
		else:
			print(720720 - a[j] * a[j] * a[j] * a[j], end=' ')
	print()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt, log2
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	y %= p - 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	(n, m) = sep()
	g = []
	for i in range(n):
		temp = lis()
		g.append(temp)
	lcmm = 1
	for i in range(n):
		for j in range(m):
			lcmm = lcm(lcmm, g[i][j])
	a = lcmm
	ans = [[0] * m for i in range(n)]
	for i in range(n):
		for j in range(m):
			ans[i][j] = a if (i + j) % 2 else a + g[i][j] ** 4
	for i in range(n):
		print(' '.join((str(i) for i in ans[i])))
testcase(1)


from math import *
a = 1
for i in range(1, 17):
	a = i * a // gcd(i, a)
A = []
(n, m) = map(int, input().split())
for i in range(n):
	A.append([*map(int, input().split())])
for i in range(n):
	for j in range(m):
		if i + j & 1:
			print(a + A[i][j] ** 4, end=' ')
		else:
			print(a, end=' ')
	print()


from math import *
l = 1
for i in range(2, 17):
	l = l * i // gcd(l, i)
(a, b) = map(int, input().split())
m = []
for i in range(a):
	m.append(list(map(int, input().split())))
	for j in range(b):
		if (i + j) % 2:
			print(l, end=' ')
		else:
			print(l + m[i][j] ** 4, end=' ')
	print()


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def A(n):
	return [0] * n

def AI(n, x):
	return [x] * n

def G(n):
	return [[] for i in range(n)]

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
mod = 10 ** 9 + 7
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	fact(x, mod)
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa.reverse()

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def floorsum(a, b, c, n):
	if a == 0:
		return b // c * (n + 1)
	if a >= c or b >= c:
		return floorsum(a % c, b % c, c, n) + b // c * (n + 1) + a // c * n * (n + 1) // 2
	m = (a * n + b) // c
	return n * m - floorsum(c, c - b - 1, a, m - 1)

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class ST:

	def __init__(self, arr):
		n = len(arr)
		mx = n.bit_length()
		self.st = [[0] * mx for i in range(n)]
		for i in range(n):
			self.st[i][0] = arr[i]
		for j in range(1, mx):
			for i in range(n - (1 << j) + 1):
				self.st[i][j] = max(self.st[i][j - 1], self.st[i + (1 << j - 1)][j - 1])

	def query(self, l, r):
		if l > r:
			return -inf
		s = (r + 1 - l).bit_length() - 1
		return max(self.st[l][s], self.st[r - (1 << s) + 1][s])

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return flag

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		seen.add(u)
		for (v, w) in graph[u]:
			if v not in d or d[v] > d[u] + w:
				d[v] = d[u] + w
				heappush(heap, (d[v], v))
	return d

def lcm(a, b):
	return a * b // gcd(a, b)

def lis(nums):
	res = []
	for k in nums:
		i = bisect.bisect_left(res, k)
		if i == len(res):
			res.append(k)
		else:
			res[i] = k
	return len(res)

def RP(nums):
	n = len(nums)
	s = set(nums)
	d = {}
	for (i, k) in enumerate(sorted(s), 1):
		d[k] = i
	bi = BIT([0] * (len(s) + 1))
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += bi.query(d[nums[i]] - 1)
		bi.update(d[nums[i]], 1)
	return ans

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j, n, m):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

def topo(n):
	q = deque()
	res = []
	for i in range(1, n + 1):
		if ind[i] == 0:
			q.append(i)
			res.append(i)
	while q:
		u = q.popleft()
		for v in g[u]:
			ind[v] -= 1
			if ind[v] == 0:
				q.append(v)
				res.append(v)
	return res

@bootstrap
def gdfs(r, p):
	if len(g[r]) == 1 and p != -1:
		yield None
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None
t = 1
for i in range(t):
	(n, m) = RL()
	c = 720720
	a = []
	for i in range(n):
		a.append(RLL())
	ans = [[c] * m for i in range(n)]
	for i in range(n):
		for j in range(m):
			if i + j & 1:
				ans[i][j] = c - a[i][j] ** 4
	for i in range(n):
		print(*ans[i])


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *

def solve():
	(n, m) = iia()
	arr = []
	for _ in range(n):
		arr.append(iia())
	lcm = 1
	for i in range(1, 17):
		lcm = lcm * i // gcd(lcm, i)
	for i in range(n):
		for j in range(m):
			val = arr[i][j]
			if (i + j) % 2 == 0:
				arr[i][j] = lcm
			else:
				arr[i][j] = lcm - val * val * val * val
	[print(*arr[i]) for i in range(n)]
solve()


(n, m) = map(int, input().split())
k = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			print(360360 * 2, end=' ')
		else:
			print(360360 * 2 + k[i][j] ** 4, end=' ')
	print()


def pri(arr, n):
	for i in range(n):
		print(arr[i], end=' ')
	return
(n, m) = map(int, input().split(' '))
arr = []
for i in range(n):
	a = list(map(int, input().split(' ')))
	arr.append(a)
b = []
t = 720720
for i in range(n):
	k = []
	for j in range(m):
		if (i + j) % 2 == 0:
			z = t
			k.append(z)
		else:
			z = t + arr[i][j] ** 4
			k.append(z)
	b.append(k)
for i in range(n):
	pri(b[i], m)
	print()


import sys
input = sys.stdin.buffer.readline
(N, M) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
for i in range(N):
	for j in range(M):
		if i + j & 1:
			A[i][j] = 720720 - A[i][j] ** 4
		else:
			A[i][j] = 720720
	print(*A[i])


import math
import sys
input = iter(sys.stdin.read().splitlines()).__next__
LCM = 720720
memo = [LCM - i ** 4 for i in range(17)]
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [[] for _ in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			b[i].append(LCM)
		else:
			b[i].append(memo[a[i][j]])
for row in b:
	print(*row)


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
	for j in range(M):
		if (i + j) % 2:
			a[i][j] = 720720
		else:
			a[i][j] = 720720 - a[i][j] ** 4
	print(*a[i])


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
from collections import defaultdict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj

def sieve():
	li = [True] * (10 ** 3 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	(prime, cur) = ([0] * 200, 0)
	for i in range(10 ** 3 + 5):
		if li[i] == True:
			prime[cur] = i
			cur += 1
	return prime

def SPF():
	mx = 10 ** 6 + 1
	spf[1] = 1
	for i in range(2, mx):
		if spf[i] == 1000000000.0:
			spf[i] = i
			for j in range(i * i, mx, i):
				if i < spf[j]:
					spf[j] = i
	return

def prime(n, d):
	prm = set()
	while n != 1:
		prm.add(spf[n])
		n = n // spf[n]
	for ele in prm:
		d[ele] = d.get(ele, 0) + 1
	return
mod = 998244353
inf = 10000000000000000

def solve():
	(n, m) = IP()
	li = []
	for i in range(n):
		l = L()
		li.append(l)
	ans = [[0 for j in range(m)] for i in range(n)]
	for i in range(n):
		for j in range(m):
			if (i + j) % 2:
				ans[i][j] = 720720 + li[i][j] ** 4
			else:
				ans[i][j] = 720720
	for ele in ans:
		print(*ele)
	return
t = 1
for i in range(t):
	solve()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [[720720] * m for i in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 1:
			B[i][j] += A[i][j] ** 4
for b in B:
	print(*b)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
b = [[720720 for i in range(m)] for j in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			b[i][j] += pow(a[i][j], 4)
for i in b:
	print(*i)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			print(720720, end=' ')
		else:
			print(720720 + pow(a[i][j], 4), end=' ')
	print('')


import sys
(n, m) = map(int, sys.stdin.readline().strip().split())
a = []
for _ in range(n):
	a.append(list(map(int, sys.stdin.readline().strip().split())))
magic_const = 2 ** 4 * 3 ** 2 * 5 * 7 * 11 * 13
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			a[i][j] = magic_const
		else:
			a[i][j] = magic_const - a[i][j] ** 4
for i in range(n):
	print(*a[i])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
(n, m) = map(int, input().split())
a = []
for i in range(n):
	a += [list(map(int, input().split()))]
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			a[i][j] = 720720 - a[i][j] ** 4
		else:
			a[i][j] = 720720
for i in a:
	print(*i, sep=' ')


def iseven(n):
	return n & 1 == 0
lcm = 720720
(n, m) = map(int, input().split(' '))
arr = []
for i in range(n):
	lst = list(map(int, input().split(' ')))
	arr.append(lst)
b = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	for j in range(m):
		if iseven(i + j):
			b[i][j] = lcm
		else:
			b[i][j] = lcm + arr[i][j] ** 4
for i in range(n):
	for j in range(m):
		if j == m - 1:
			print(b[i][j])
		else:
			print(b[i][j], end=' ')


inn = lambda : int(input())
inm = lambda : map(int, input().split())
ins = lambda : str(input())
ina = lambda : list(map(int, input().split()))
lcm = 720720

def solve():
	(n, m) = inm()
	a = [0 for i in range(n)]
	for (i, v) in enumerate(a):
		a[i] = ina()
	for i in range(n):
		for j in range(m):
			a[i][j] = lcm + (a[i][j] ** 4 if (i + j) % 2 else 0)
	for i in a:
		print(*i)

def main():
	t = 1
	for _ in range(t):
		solve()
main()


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=-10 ** 6, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(200001)]
pp = [0] * 200001

def SieveOfEratosthenes(n=200000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
(n, m) = map(int, input().split())
a = []
res = [[0 for i in range(m)] for j in range(n)]
l = 1
for i in range(n):
	ar = list(map(int, input().split()))
	for j in ar:
		l = l * j // math.gcd(l, j)
	a.append(ar)
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			res[i][j] = l
		else:
			res[i][j] = l + a[i][j] ** 4
	print(*res[i])


import sys
import os.path
from collections import *
import math
import bisect
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
sqrt = math.sqrt
gcd = math.gcd
num = 1
for i in range(2, 17):
	num = num * i // gcd(num, i)
(m, n) = [int(x) for x in input().split()]
arr = [0] * m
for i in range(m):
	arr[i] = [int(x) for x in input().split()]
res = 0
for i in range(m):
	for j in range(res, n, 2):
		arr[i][j] = num
	res = 1 - res
res = 1
for i in range(m):
	for j in range(res, n, 2):
		arr[i][j] = num - arr[i][j] ** 4
	res = 1 - res
for i in range(m):
	for j in range(n):
		print(arr[i][j], end=' ')
	print()


(n, m) = [int(x) for x in input().split(' ')]
a = []
for l in range(n):
	b = [int(x) for x in input().split(' ')]
	a.append(b)
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			print(720720, end=' ')
		else:
			print(720720 + a[i][j] ** 4, end=' ')
	print()


import sys
from sys import stdin
tt = 1
for loop in range(tt):
	(n, m) = map(int, stdin.readline().split())
	a = [list(map(int, stdin.readline().split())) for i in range(n)]
	b = [[None] * m for i in range(n)]
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				b[i][j] = 720720
			else:
				b[i][j] = 720720 - a[i][j] ** 4
	for i in b:
		print(*i)


import math
(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			l[i][j] = l[i][j] ** 4 + 720720
		else:
			l[i][j] = 720720
for i in l:
	print(*i)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 51, func=lambda a, b: a & b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm
(n, m) = map(int, input().split())
l = []
lc = 1
ans = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	l.append(list(map(int, input().split())))
	for j in range(m):
		lc = find_lcm(lc, l[i][j])
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			ans[i][j] = lc
		else:
			ans[i][j] = lc + l[i][j] ** 4
	print(*ans[i])


from sys import stdin
(n, m) = map(int, stdin.readline().split())
board = []
for _ in range(n):
	row = list(map(int, stdin.readline().split()))
	board.append(row)
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			board[i][j] = 720720
		else:
			board[i][j] = 720720 + board[i][j] ** 4
for row in board:
	print(' '.join(map(str, row)))


from collections import defaultdict
from itertools import accumulate
import bisect
import sys
input = sys.stdin.readline
inf = 100000000000000000
mod = 998244353
(n, m) = map(int, input().split())
A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	A[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		B[i][j] = 720720
		if (i + j) % 2 == 1:
			B[i][j] += A[i][j] * A[i][j] * A[i][j] * A[i][j]
for i in range(n):
	for j in range(m):
		print(B[i][j], end=' ')
	print()


from sys import stdin, stdout
import sys

def multiples_and_power_differences(n, m, b_a):
	r = 720720
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				b_a[i][j] = r
			else:
				b_a[i][j] = r - b_a[i][j] ** 4

def lcm(a, b):
	g = gcd(a, b)
	return a * b // g

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
try:
	(n, m) = map(int, stdin.readline().split())
	b_a = []
	for _ in range(n):
		b_a.append(list(map(int, stdin.readline().split())))
	multiples_and_power_differences(n, m, b_a)
	for b in b_a:
		stdout.write(' '.join(map(str, b)) + '\n')
except:
	print(sys.exc_info())


import sys, os, io
import math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
lcm = 1
for i in range(2, 17):
	lcm = lcm * i // math.gcd(lcm, i)
(n, m) = [int(i) for i in input().split()]
grid = [[lcm] * m for i in range(n)]
a = []
for i in range(n):
	a.append([int(i) for i in input().split()])
for i in range(n):
	for j in range(m):
		num = a[i][j] ** 4
		flag = 1
		while flag:
			flag = 0
			if i > 0 and grid[i][j] == grid[i - 1][j]:
				grid[i][j] += num
				flag = 1
			if j > 0 and grid[i][j] == grid[i][j - 1]:
				grid[i][j] += num
				flag = 1
for i in range(n):
	print(*grid[i])


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
ans = [[720720] * M for _ in range(N)]
for i in range(N):
	for j in range(M):
		if (i + j) % 2:
			continue
		ans[i][j] -= A[i][j] ** 4
for row in ans:
	print(*row)


(n, m) = list(map(int, input().split()))
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(m):
		c = 720720
		if (i + j) % 2 == 1:
			c -= l[j] ** 4
		print(c, end=' ')
	print()


def inputs():
	return map(int, input().split())
(n, m) = inputs()
lcm = 720720
for i in range(n):
	a = list(inputs())
	for j in range(m):
		if (i ^ j) & 1:
			print(lcm, end=' ')
		else:
			print(lcm - a[j] ** 4, end=' ')
	print()


import math
ans = []
(n, m) = map(int, input().split())
for _ in range(n):
	ans.append([720720 for i in range(m)])
for i in range(n):
	x = list(map(int, input().split()))
	for j in range(m):
		if (i + j) % 2:
			ans[i][j] += x[j] ** 4
for i in range(n):
	print(*ans[i])


import sys
input = sys.stdin.readline
from math import gcd
from functools import reduce
lcm = lambda x, y: x * y // gcd(x, y)
L = reduce(lcm, range(1, 17))
(m, n) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]
B = [[L] * n for _ in range(m)]
for i in range(m):
	for j in range(n):
		if (i + j) % 2:
			B[i][j] += A[i][j] ** 4
for b in B:
	print(*b)


import math
from collections import defaultdict
from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
lcm = 720720
mat = []
for i in range(n):
	mat.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			print(lcm, end=' ')
		else:
			print(lcm + mat[i][j] ** 4, end=' ')
	print()


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
a = []
for _ in range(n):
	a.append([int(x) for x in input().split()])
for x in range(n):
	for y in range(m):
		if (x + y) % 2 == 0:
			print(720720, end=' ')
		else:
			print(720720 - a[x][y] ** 4, end=' ')
	print()


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()

def FACT(n, mod):
	s = 1
	facts = [1]
	for i in range(1, n + 1):
		s *= i
		s %= mod
		facts.append(s)
	return facts[n]

def C(n, k, mod):
	return FACT(n, mod) * pow(FACT(k, mod) * FACT(n - k, mod) % mod, mod - 2, mod) % mod

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
(n, m) = MI()
l = []
for i in range(n):
	l.append(LI())
d = [[0 for j in range(m)] for i in range(n)]
temp = 1
for i in range(1, 17):
	temp = lcm(temp, i)
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			d[i][j] = temp
		else:
			d[i][j] = temp + l[i][j] ** 4
	print(*d[i])


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
lcm = 720720
for i in range(n):
	line = []
	for j in range(m):
		if (i + j) % 2 == 0:
			line.append('%d' % (lcm + a[i][j] ** 4))
		else:
			line.append('%d' % lcm)
	print(' '.join(line))


from collections import defaultdict, deque, Counter
import sys
import bisect
import math
input = sys.stdin.readline
mod = 1000000007
(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append([int(i) for i in input().split() if i != '\n'])
ans = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	for j in range(m):
		if i + j & 1:
			ans[i][j] = 720720
		else:
			ans[i][j] = 720720 + l[i][j] ** 4
for i in range(n):
	print(*ans[i])


def __gcd(a, b):
	if a == 0:
		return b
	return __gcd(b % a, a)
(n, m) = map(int, input().strip().split())
a = []
for _ in range(n):
	a.append([int(it) for it in input().split()])
gcd = 0
lcm = 1
for i in range(1, 17):
	lcm = lcm * i / __gcd(lcm, i)
lcm = int(lcm)
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			a[i][j] = lcm
		else:
			a[i][j] = lcm + a[i][j] ** 4
for i in range(n):
	print(*a[i])


import math
from functools import reduce

def lcm_base(x, y):
	return x // math.gcd(x, y) * y

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)
import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
num = lcm(*[i for i in range(1, 17)])
ans = [[num] * m for i in range(n)]
for i in range(n):
	for j in range(i % 2, m, 2):
		ans[i][j] -= a[i][j] ** 4
for i in ans:
	print(*i)


(n, m) = map(int, input().split())
x = 720720
for i in range(n):
	row = [int(x) for x in input().split()]
	for j in range(m):
		print(x if i + j & 1 else x + row[j] ** 4, end=' ')
	print()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(plan, new) = ([[int(i) for i in input().split()] for _ in range(n)], [[0 for i in range(m)] for _ in range(n)])
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			new[i][j] = 720720
		else:
			new[i][j] = 720720 + plan[i][j] ** 4
for i in range(n):
	print(*new[i])


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7
(h, w) = MI()
aa = LLI(h)
bb = [[720720] * w for _ in range(h)]
for i in range(h):
	for j in range(w):
		if i + j & 1:
			bb[i][j] += aa[i][j] ** 4
for row in bb:
	print(*row)


(n, m) = map(int, input().split())
v = []
ans = []
for i in range(n):
	v.append(list(map(int, input().split())))
	ans.append([720720] * m)
	for j in range(m):
		if (i + j) % 2 == 1:
			ans[i][j] += v[i][j] ** 4
		print(ans[i][j], end=' ')
	print()


def find():
	(n, m) = map(int, input().split())
	mas = [tuple(map(int, input().split())) for i in range(n)]
	for i in range(n):
		for j in range(m):
			if (j + i) % 2 == 0:
				print(720720, end=' ')
			else:
				print(720720 + mas[i][j] ** 4, end=' ')
		print()
find()


LCM = 720720
(n, m) = map(int, input().split())
matrix = []
for _ in range(n):
	row = [int(col) for col in input().split()]
	matrix.append(row)
for i in range(n):
	for j in range(m):
		matrix[i][j] = 0 if (i + j) % 2 else matrix[i][j] ** 4
		matrix[i][j] += LCM
output = '\n'.join((' '.join((str(col) for col in row)) for row in matrix))
print(output)


def main():
	(n, m) = map(int, input().split())
	l = []
	world = 720720
	quads = []
	for i in range(1, 31):
		quads.append(i ** 4)
	for i in range(1, 17):
		for quad in quads:
			if (world - quad) % i == 0:
				l.append(quad)
				break
	for i in range(n):
		row = list(map(int, input().split()))
		p = []
		for j in range(m):
			if (i + j) % 2 == 0:
				p.append(world)
			else:
				p.append(world - quads[row[j] - 1])
		print(*p)
main()


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	(n, m) = mi()
	lcm = 1
	for i in range(2, 17):
		lcm = lcm * i // gcd(lcm, i)
	for i in range(n):
		x = li()
		for j in range(m):
			if i + j & 1:
				print(lcm, end=' ')
			else:
				print(lcm + x[j] ** 4, end=' ')
		print()
if file:
	if path.exists('tmp/input.txt'):
		sys.stdin = open('tmp/input.txt', 'r')
		sys.stdout = open('tmp/output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil

def st():
	return list(stdin.readline().strip())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def inp():
	return int(stdin.readline())

def pr(n):
	return stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, m) = mp()
	l = [li() for i in range(n)]
	for i in range(n):
		for j in range(m):
			x = l[i][j]
			if (i + j) % 2 == 0:
				print(720720 + pow(x, 4), end=' ')
			else:
				print(720720, end=' ')
		print()
for _ in range(1):
	solve()


def arrIn():
	return list(map(int, input().split()))

def mapIn():
	return map(int, input().split())
(n, m) = mapIn()
x = [0] * m
a = []
for i in range(n):
	a.append(arrIn())
for i in range(n):
	for j in range(m):
		if (i + j) % 2 == 0:
			print(720720, end=' ')
		else:
			print(720720 + a[i][j] ** 4, end=' ')
	print()


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
l = 1
for i in range(1, 17):
	l = l * i // gcd(l, i)
(n, m) = mp()
ml = [lmp() for i in range(n)]
for i in range(n):
	for j in range(m):
		if (i + j) % 2:
			print(l, end=' ')
		else:
			print(l - ml[i][j] ** 4, end=' ')
	print()


def lcm(x, y):
	return x * y // gcd(x, y)

def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x
cumulcm = 1
for i in range(1, 17):
	cumulcm = lcm(cumulcm, i)
c = cumulcm
zs = []
k = 1
while k ** 4 < 10 ** 6:
	zs.append(k ** 4)
	k += 1
alternateY = [-1 for _ in range(17)]
for y in range(1, 17):
	ok = False
	for z in zs:
		if (c - z) % y == 0:
			ok = True
			k = (c - z) // y
			break
	alternateY[y] = k * y
	assert ok == True

def main():
	(n, m) = readIntArr()
	a = []
	for _ in range(n):
		a.append(readIntArr())
	b = [[-1 for _ in range(m)] for __ in range(n)]
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				b[i][j] = c
			else:
				b[i][j] = alternateY[a[i][j]]
	multiLineArrayOfArraysPrint(b)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]
inf = float('inf')
MOD = 10 ** 9 + 7
main()


(n, m) = map(int, input().split())
arr = [[int(num) for num in input().split()] for _ in range(n)]
lcm = 720720
for i in range(n):
	line = []
	for j in range(m):
		if (i + j) % 2 == 0:
			line.append(str(lcm + arr[i][j] ** 4))
		else:
			line.append(str(lcm))
	print(' '.join(line))