#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define all(v) (v).begin(), (v).end()
using vi = vector<int>;
using ii = pair<int, int>;
using ld = long double;

//BEGIN-LIB:
//END-LIB:

const int X = 720720;

int main () {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int x;
            cin >> x;
            if (i + j & 1) {
                x *= x;
                x *= x;
                cout << X + x << ' ';
            } else {
                cout << X << ' ';
            }
        }
        cout << '\n';
    }
}