#include<bits/stdc++.h>
using namespace std;
const int lcm=720720;
int b[502][502];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			b[i][j]=lcm;
			int tmp;
			cin>>tmp;
			if(b[i-1][j]==lcm||b[i][j-1]==lcm||b[i+1][j]==lcm||b[i][j+1]==lcm)
			{
				b[i][j]-=pow(tmp,4);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<b[i][j]<<" ";
		}
		cout<<endl;
	}	
}