#include <bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
typedef double db;
const ll inf=1ll<<58;
const int N=1e3+10;
const int mod=1e9+7;
typedef pair<int,int> pii;

int a[N][N],b[N][N];
void solve(){
	int n,m;
	sc("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j){
			sc("%d",&a[i][j]);
			if((i+j)&1)
				b[i][j]=720720;
			else
				b[i][j]=720720+a[i][j]*a[i][j]*a[i][j]*a[i][j];
			pr("%d%c",b[i][j]," \n"[j==m]);
		}
}

signed main()
{
	int T;
//	sc("%d",&T);
	T=1;
	while(T--)solve();
	return 0;
}