#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++, puts(""))
		for (int j = 1; j <= m; j++) {
			int a; scanf("%d", &a);
			if ((i + j) & 1)
				printf("%d ", 720720 - a * a * a * a);
			else	printf("720720 ");
		}
	return 0;
}