def setmatrix(l,r,c):
    row=[0]*r
    col=[0]*c
    # for i in range(r):
    #     row[i]=0
    # for i in range(c):
    #     col[i]=0    
    for i in range(r):
        for j in range(c):
            if(l[i][j]==0):
                row[i]=1
                col[j]=1
    for i in range(r):
        for j in range(c):
            if(row[i]==1 or col[j]==1):
                l[i][j]=0
                
def display(l,r,c):
    for i in range(r):
        for j in range(c):
            print(l[i][j],end=" ")
        print()    

r,c=map(int,input().split())
l=[]
for i in range(r):
    l.append([int(j) for j in input().split()])
setmatrix(l,r,c)    
display(l,r,c)

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: