#include <iostream>
#include<map>
#include<vector>
#include<climits>
#include<queue>
#include<cmath>
#include<stack>
#include<string>
#include<algorithm>
#define pb push_back
#define N (lli)(3e5)
#define lli  long long int
#define mod (lli)(998244353)
#define INF (1e9)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
using namespace std;
// Jai Hanuman Gyan Gun Sagar Jai Kapis Ti Log Ujagar
int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>>arr(n,vector<int>(m));
    vector<vector<int>>soln(n,vector<int>(m));
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            cin>>arr[i][j];
            if((i+j)%2==0) soln[i][j] = 720720;
            else soln[i][j] = 720720 + arr[i][j]*arr[i][j]*arr[i][j]*arr[i][j];
        }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)  cout<<soln[i][j]<<" ";
        cout<<endl;
    }
    
    
    
    
    
}
