m,n=map(int,input().split())
L=[]
Ln=[]
for _ in range(m):
L.append([int(x) for x in input().split()])
for i in range(m):
Ln.append(L[i].copy())
i=0
while i<m:
j=0
while j<n:
if L[i][j]==1:
re=j
if j==n-1:
break
else:
j+=1
while L[i][j]!=1 and j!=n-1:
j+=1
if L[i][j]==1:
for u in range(re+1,j):
Ln[i][u]=1
j+=1
i+=1
for i in Ln:
print(*i)