#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,x,y;
long long a[100][100]={0},b[100][100]={0};
cin>>x>>y;
for(i=1;i<=x;i++)
{
for(j=1;j<=y;j++)
{
cin>>a[i][j];
}
}
for(i=1;i<=x;i++)
{
for(j=1;j<=y;j++)
{
if(i==1||j==1||i==x||j==y)
{
b[i][j]=a[i][j];
}
else
{
b[i][j]=round((a[i-1][j]+a[i+1][j]+a[i][j-1]+a[i][j+1]+a[i][j])/5.0);
}
cout<< b[i][j]<<' ';
}
cout<< endl;
}
return 0;
}