#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define per(i,a,b) for(ll i=(b)-1;i>=(a);i--)
using ll=long long;
using vi=vector<int>;
int get_4th(int x) { return x*x*x*x; }
int main(){
    ios_base::sync_with_stdio(0);
    int n,m;
    cin>>n>>m; vector<vi> a(n,vi(m));
    rep(i,0,n) rep(j,0,m) cin>>a[i][j];
    int k=16*9*5*7*11*13;
    rep(i,0,n) {
        rep(j,0,m) cout<<k+((i+j)&1?get_4th(a[i][j]):0)<<" ";
        cout<<"\n";
    }
}