```python
import copy
n,m=map(int,input().split())
a=[]
for i in range(n):
c=list(map(int,input().split()))
a.append(c)
an=copy.deepcopy(a)
for i in range(1,n-1):
for j in range(1,m-1):
k=(a[i-1][j]+a[i+1][j]+a[i][j-1]+a[i][j+1]+a[i][j])/5
f = 0
if k*10%10 >= 5:
f = 1
if f == 0:
an[i][j] = int(k)
else:
an[i][j] = int(k)+1
for i in range(len(an)):
for j in range(len(an[i])):
print(an[i][j],end=" ")
print()
```
by Botter @ 2023-10-23 16:03:31