#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#define ll long long
#define rep(i, a, b) for (int i = a; i <= (int)b; i ++)
#define per(i, a, b) for (int i = (int)a; i >= b; i --)
using namespace std;
int n, m;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main()
{
    int tmp = 2;
    rep(i, 3, 16) tmp = i / gcd(tmp, i) * tmp;
    scanf("%d %d", &n, &m);
    rep(i, 1, n) rep(j, 1, m) {
        int x; scanf("%d", &x);
        if((i + j) % 2) x = tmp + x * x * x * x;
        else x = tmp;
        printf("%d%c", x, " \n"[j == m]);
    }
    return 0;
}