#include <bits/stdc++.h>
#define ft first
#define sd second
#define ll long long
#ifdef LOCAL
    #include "debughead.h"
#else
    #define dbg(...) 0
#endif

#define sz(x) (x).size()
using namespace std;


int n, m;
int a[505][505];
int b[505][505];

set <int> s1, s2;

int gcd(int a, int b) {
    if(a == 0) return b;
    return gcd(b % a, a);
}

bool vis[100];

void solve() {
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(i % 2 == j % 2) {
                cout << 720720 - a[i][j]*a[i][j]*a[i][j]*a[i][j] << " ";
            }
            else {
                cout << 720720 << " ";
            }
        }
        cout << "\n";
    }
}

int main()
{
    #ifndef LOCAL
        ios_base::sync_with_stdio(0); cin.tie(0);
    #endif // LOCAL
    int t = 1;
   // cin >> t;
    while(t--)
        solve();

    return 0;
}
