#include <bits/stdc++.h>
#define int long long int
using namespace std;
int a[505][505];
int b[505][505];
int lc = 720720;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n , m;
    cin>>n>>m;
    for(int i = 1;i<= n;i++){
        for(int j = 1;j<= m;j++){
            cin>>a[i][j];
        }
    }
    for(int i = 1;i<= n;i++){
        for(int j = 1;j<= m;j++){
            if( (i+j)%2 == 0  ){
                b[i][j] = lc;
            }
            else{
                b[i][j] = lc - a[i][j]*a[i][j]*a[i][j]*a[i][j];
            }
        }
    }
    for(int i = 1;i<= n;i++){
        for(int j = 1;j<= m;j++){
            cout<<b[i][j]<<" ";
        }
        cout<<"\n";
    }
}
