#include <bits/stdc++.h>
using namespace std;
 
typedef long double ld;
const long long inf = 1100000000000000000;
#define maxn 1000005
#define mod 1000000007 //998244353
#define int long long
#define PB push_back
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define pii pair <int,int>
#define vi vector<int>
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define sz(x) (int)((x).size())  
#define mem(a,x) memset(a,x,sizeof(a))
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;

void solve(){
	int n, m; cin>>n>>m;
	int z = 720720; //lcm{1..16}
	int a[n][m];
	rep(i, 0, n)	
		rep(j, 0, m)	
			cin>>a[i][j];
	rep(i, 0, n){
		rep(j, 0, m){
			int k = z-pow(a[i][j], 4);
			if((i+j)%2)
				cout<<z<<" ";
			else
				cout<<k<<" ";
		}cout<<"\n";
	}
}

signed main(){
    ios_base::sync_with_stdio(false), cin.tie(nullptr); 
    int T=1;// cin>>T; 
    while(T--){
        solve();cout<<'\n';
    }
    return 0;
}