#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <random>

using namespace std;

void solve() {
    int n, m;
    cin>>n>>m;
    vector < vector < int > > a(n, vector < int > (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++, cout<<"\n") {
        for (int j = 0; j < m; j++) {
            if ((i + j) % 2 == 0) {
                cout<<"720720 ";
            } else {
                cout<<(720720 + (int)pow(a[i][j], 4))<<" ";
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    int t = 1;
    while (t--)
        solve();
}