---
# System prepended metadata

title: ZeroJudge e971 Python
tags: [zerojudge, python]

---

ZeroJudge e971
```python=
m,n = map(int,input().split())
for i in range(m):
    row = input().split()
    p = [] #index of 1
    for j,c in enumerate(row):
        if c=='1': p.append(j)
    for j in range(1,len(p),2): #every pair of 1
        row[p[j-1]:p[j]] = ['1']*(p[j]-p[j-1])
    print(*row)
    
```