Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner:

$a_{1} OR a_{2} OR \ldots OR a_{k}$ where $a_{i} \in \{0,1 \}$ is equal to 1 if some a_{i} = 1, otherwise it is equal to 0.

Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as A_{ij}. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:

[Image].

(B_{ij} is OR of all elements in row i and column j of matrix A)

Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large.


-----Input-----

The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively.

The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1).


-----Output-----

In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one.


-----Examples-----
Input
2 2
1 0
0 0

Output
NO

Input
2 3
1 1 1
1 1 1

Output
YES
1 1 1
1 1 1

Input
2 3
0 1 0
1 1 1

Output
YES
0 0 0
0 1 0

Difficulty: interview

Starter code:

Solutions:
import sys

m, n = map(int, input().split())
a = []
for _ in range(m):
	a.append(list(map(int, input().split())))
b = [[1]*n for _ in range(m)]
for i in range(m):
	for j in range(n):
		if(a[i][j] == 0):
			b[i] = [0]*n
			for k in range(m):
				b[k][j] = 0
for i in range(m):
	for j in range(n):
		if(a[i][j] == 1):
			good = False
			if(1 in b[i]):
				good = True
			else:
				for k in range(m):
					if(b[k][j] == 1):
						good = True
			if not good:
				print('NO')
				return
print("YES")
for i in b:
	print(' '.join([str(t) for t in i]))

n, m = list(map(int, input().split()))
a = [[0 for x in range(0, 200)] for x in range(0, 200)]

for i in range(0, n):
	b = input()
	a[i] = b.split(' ')

for i in range(0, n):
	for j in range(0, m):
		a[i][j] = int(a[i][j])

ans = [[1 for x in range(0, 200)] for x in range(0, 200)]

for i in range(0, n):
	for j in range(0, m):
		if(a[i][j] == 0):
			for i1 in range(0, n):
				ans[i1][j] = 0
			for j1 in range(0, m):
				ans[i][j1] = 0

b = [[1 for x in range(0, 200)] for x in range(0, 200)]

for i in range(0, n):
	for j in range(0, m):
		b[i][j] = 0
		for j1 in range(0, m):
			b[i][j] = b[i][j]|ans[i][j1]
		for i1 in range(0, n):
			b[i][j] = b[i][j]|ans[i1][j]
		if(b[i][j] != a[i][j]):
			print('NO')
			return

print('YES')
for i in range(0, n):
	res = ''
	for j in range(0, m):
		res = res + str(ans[i][j])
		res = res + ' '
	print(res)


from collections import defaultdict
g = defaultdict(list)
row = defaultdict(int)
column = defaultdict(int)
ng = defaultdict(list)
gg = defaultdict(list)


n,m= (int(x) for x in input('').split())
for i in range(n):
    g[i]=[int(x) for x in input('').split()]
    ng[i]= [0] * m
    gg[i]= [0] * m
for i in range(n):
    row[i] = all(g[i])
for j in range(m):
    column[j] = all(g[i][j] for i in range(n))

for i in range(n):
    for j in range(m):
        ng[i][j] = int(row[i] and column[j])

for i in range(n):
    if any(ng[i]):
        gg[i] = [1]*m

for j in range(m):
    if any(ng[i][j] for i in range(n)):
        for i in range(n):
            gg[i][j] = 1


#print(g)
#print(row)
#print(column)
#print(ng)
#print(gg)
if gg == g:
    print('YES')
    for i in range(n):
        print(' '.join(str(x) for x in ng[i]))
else:
    print('NO')




[M,N] = [int(s) for s in input().split()]
B = []
for i in range(M):
    row = [int(s) for s in input().split()]
    B.append(row)

A = [[1 for j in range(N)] for i in range(M)]
for i in range(M):
    for j in range(N):
        if B[i][j]==0:
            A[i] = [0 for j in range(N)]
            for k in range(M): A[k][j] = 0

B1 = [[0 for j in range(N)] for i in range(M)]
for i in range(M):
    for j in range(N):
        if A[i][j]==1:
            B1[i] = [1 for j in range(N)]
            for k in range(M): B1[k][j] = 1

if B!=B1:
    print("NO")
else:
    print("YES")
    for i in range(M):
        print(' '.join(map(str,A[i])))
    



m, n = map(int, input().split())
row = [True] * m
col = [True] * n
a = [[0] * n for _ in range(m)]
for i in range(m):
    s = list(map(int, input().split()))
    for j in range(n):
        if (s[j] == 0):
            row[i] = False
            col[j] = False
        a[i][j] = s[j]
c = 0
r = 0
for i in range(n):
    if col[i]:
        c+=1
for j in range(m):
    if row[j]:
        r+=1
res = []
if (r > 0 and c > 0) or (r == 0 and c == 0):
    for i in range(m):
        res.append([])
        for j in range(n):
            if col[j] and row[i]:
                res[i].append(1)
            elif a[i][j] == 0 or (col[j] or row[i]):
                res[i].append(0)
            else:
                print('NO')
                return

    print('YES')
    for i in range(m):
        s = ' '.join(list(map(str, res[i])))
        print(s)
else:
    print('NO')

n, m = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
b = []
for i in range(n):
    b.append([0] * m)

def fill(x, y):
    for i in range(n):
        b[i][y] = 1
    for i in range(m):
        b[x][i] = 1

def getv(c, x, y):
    res = False
    for i in range(n):
        res = res or c[i][y]
    for i in range(m):
        res = res or c[x][i]
    return res

def getv2(c, x, y):
    res = True
    for i in range(n):
        res = res and c[i][y]
    for i in range(m):
        res = res and c[x][i]
    return res



for i in range(n):
    for j in range(m):
        if getv2(a,i,j):
            b[i][j] = 1


good = True
for i in range(n):
    for j in range(m):
        if a[i][j] != getv(b, i, j):
            good = False

if good == False:
    print("NO")
else:
    print("YES")
    for i in range(n):
        for j in range(m-1):
            print(b[i][j],end=' ')
        print(b[i][m-1])

def check(a, b, m, n):
	for i in range(m):
		for j in range(n):
			k = 0 
			for x in range(m):
				k |= a[x][j]
			for x in range(n):
				k |= a[i][x]
			if k != b[i][j]:
				return False
	return True

input_values = lambda: [int(x) for x in input().split()]
m, n = input_values()
b = []
for i in range(m):
	b.append(input_values())
a = [[1 for j in range(n)] for i in range(m)]
for i in range(m):
	for j in range(n):
		if b[i][j] == 0:
			for x in range(m):
				a[x][j] = 0
			for x in range(n):
				a[i][x] = 0
if check(a, b, m, n):
	print('YES')
	for i in range(m):
		print(' '.join([str(x) for x in a[i]]))
else:
	print('NO')


'''
Created on 11-Nov-2014

@author: akash
'''
def transform(a, n, m):
    row = [False for i in range(n)]
    col = [False for i in range(m)]
    mat = [[True for i in range(m)] for j in range(n)]
    for i in range(n):
        for j in range(m):
            if a[i][j] == False:
                row[i] = True
                col[j] = True
    for i in range(n):
        for j in range(m):
            if row[i] == True or col[j] == True:       
                mat[i][j] = False
    return mat

def isvlid(inp, mat, m, n):
    row = [False for i in range(n)]
    col = [False for i in range(m)]
    newinp = [[False for i in range(m)] for j in range(n)]
    for i in range(n):
        for j in range(m):
            if mat[i][j] == True:
                row[i] = True
                col[j] = True
    for i in range(n):
        for j in range(m):
            if row[i] == True or col[j] == True:       
                newinp[i][j] = True
    for i in range(n):
        for j in range(m):
            if inp[i][j] != newinp[i][j]:
                return False
    return True
line = input()
lst = line.split()
n = int(lst[0])
m = int(lst[1])
'accpet input'
inp = [[False for i in range(m)] for j in range(n)]
for i in range(n):
    line = input()
    lst = line.split()
    for j in range(m):
        inp[i][j] = True if int(lst[j]) == 1 else False

mat = transform(inp, n, m)
if isvlid(inp, mat, m, n): 
    print("YES")
    for i in range(n):
        for j in range(m):
            if mat[i][j]:
                print("1", end=" ")
            else:
                print("0", end=" ")
        print()
else:
    print("NO")


__author__ = '-'

l1 = input().strip().split(" ")
m = int(l1[0])
n = int(l1[1])

B = []
for i in range(m):
    line = input().strip().split(" ")
    row = []
    for p in line:
        row.append(int(p))
    B.append(row)

A = [[0 for x in range(n)] for y in range(m)]

def transferA(B,m,n):
    A = [[0 for x in range(n)] for y in range(m)]

    for i in range(m):
        rida1 = True
        for j in range(n):
            if B[i][j] == 0:
                rida1 = False
                break
        if rida1:
            for j in range(n):
                veerg1 = True
                for r in range(m):
                    if B[r][j] == 0:
                        veerg1 = False
                        break
                if veerg1 and rida1:
                    A[i][j] = 1
    return A

A = transferA(B,m,n)
def transfer(A,m,n):
    C = [[0 for x in range(n)] for y in range(m)]
    for i in range(len(A)):
        for j in range(len(A[i])):
            if A[i][j] == 1:
                for k in range(n):
                    C[i][k] = 1
                for l in range(m):
                    C[l][j] = 1
    return C


C = transfer(A,m,n)

if C == B:
    print("YES")
    for i in range(len(A)):
        for j in range(len(A[i])):
            print(A[i][j],end = " ")
        print()
else:
    print("NO")


(m, n) = list(map(int, input().split(' ')))
B = []
for i in range(0,m):
	row = [int(x) for x in input().split(' ')]
	B.append(row)

B_ = []
for j in range(0,n):
	col = [B[i][j] for i in range(0,m)]
	B_.append(col)

for row in B:
	if 1 in row:
		if 0 in row:
			for j in range(0,n):
				col = [B[i][j] for i in range(0,m)]
				if (row[j]==1 and 0 in col):
					print("NO")
					return

for col in B_:
	if 1 in col:
		if 0 in col:
			for i in range(0,m):
				row = [B[i][j] for j in range(0,n)]
				if (col[i]==1 and 0 in row):
					print("NO")
					return

only1 = False
only0 = False
for row in B:
	if 1 not in row:
		only0 = True 
	if 0 not in row:
		only1 = True
if only1 and only0:
	print("NO")
	return

only1 = False
only0 = False
for col in B_:
	if 1 not in col:
		only0 = True 
	if 0 not in col:
		only1 = True
if only1 and only0:
	print("NO")
	return

A = [[0 for col in range(0,n)] for row in range(0,m)]
R = []
for i in range(0,m):
	flg = 1
	for j in range(0,n):
		if B[i][j] == 0:
			flg = 0
			break
	if flg == 1:
		R.append(i)
C = []
for j in range(0,n):
	flg = 1
	for i in range(0,m):
		if B[i][j] == 0:
			flg = 0
			break
	if flg == 1:
		C.append(j)

for r in R:
	for c in C:
		A[r][c] = 1

print("YES")
for i in range(0,m):
	s = ""+str(A[i][0])
	for j in range(1,n):
		s += " "+str(A[i][j])
	print(s)



m,n = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(m)]
sr = [sum(B[i]) for i in range(m)]
sc = [sum([B[i][j] for i in range(m)]) for j in range(n)]
for i in range(m):
  if sr[i]>0 and sr[i]<n:
    for j in range(n):
      if B[i][j] and sc[j]>0 and sc[j]<m:
        print('NO')
        return
if sum(sr) > 0 and (max(sr) < n or max(sc) < m):
  print('NO')
else:
  print('YES')
  for i in range(m):
    Ai = [1 if sr[i]==n and sc[j]==m else 0 for j in range(n)]
    print(' '.join(repr(a) for a in Ai))


m,n = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(m)]
sr = [sum(B[i]) for i in range(m)]
sc = [sum([B[i][j] for i in range(m)]) for j in range(n)]
no = sum(sr) > 0 and (max(sr) < n or max(sc) < m)

for i in range(m):
  for j in range(n):
    if B[i][j] and sc[j]%m and sr[i]%n or no:
      print('NO')
      return

print('YES')
for i in range(m):
  Ai = [(sr[i]//n)*(sc[j]//m) for j in range(n)]
  print(' '.join(repr(a) for a in Ai))


#fin, fout = open("input.txt"), open("output.txt", "w")
n, m = map(int, input().split())
#n, m = map(int, fin.readline().split())
A = [list(map(int, input().split())) for i in range(n)]
#A = [list(map(int, fin.readline().split())) for i in range(n)]
I, J = [0] * n, [0] * m
IS, JS = [0] * n, [0] * m
CountI, CountJ = 0, 0
for i in range(n):
	IS[i] = sum(A[i])
	if (IS[i] == m):
		I[i] = 1
		CountI += 1
for j in range(m):
	JS[j] = sum([A[i][j] for i in range(n)])
	if (JS[j] == n):
		J[j] = 1
		CountJ += 1
flag = True
i = 0
while i < n and flag:
	if (IS[i] != m and IS[i] != CountJ):
		flag = False
	i += 1
j = 0
while j < m and flag:
	if (JS[j] != n and JS[j] != CountI):
		flag = False
	j += 1
if (flag and not (sum(I) + sum(J) > 0 and sum(I) * sum(J) == 0)):
	print("YES")
	for i in range(n):
		for j in range(m):
			print(I[i] * J[j], end = " ")
		print()
else:
	print("NO")
#fout.close()
#fin.close()

n, m = [int(i) for i in input().split()]
sum1 = [0] * n
sum2 = [0] * m
res = [[0] * m for i in range(n)]
a = 0
k = [0] * 4
flag = False
for i in range(n):
    a = [int(i2) for i2 in input().split()]
    sum1[i] = sum(a)
    for i2 in range(m):
        sum2[i2] += a[i2]
for i in range(n):
    if sum1[i] == m:
        k[2] += 1
for i in range(m):
    if sum2[i] == n:
        k[3] += 1
for i in range(n):
    if (sum1[i] > k[3]) and not(sum1[i] == 0 or sum1[i] == m) or ((k[2] * k[3] == 0) and k[2] != k[3]):
        flag = True
for i in range(m):
    if (sum2[i] > k[2]) and not(sum2[i] == 0 or sum2[i] == n) or ((k[2] * k[3] == 0) and k[2] != k[3]):
        flag = True
if flag:
    print('NO')
else:
    print('YES')
    for i in range(n):
        for i2 in range(m):
            res[i][i2] = 1
    for i in range(m):
        if sum2[i] != n:
            for i2 in range(n):
                res[i2][i] = 0
    for i in range(n):
        if sum1[i] != m:
            for i2 in range(m):
                res[i][i2] = 0
    for i in range(n):
        for i2 in range(m):
            print(res[i][i2],end=' ')
        print()

n, m = map(int, input().split())
tab = [[int(i) for i in input().split()] for j in range(n)]
ans = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
    for j in range(m):
        z = 1
        for k in tab[i]:
            z = z and k
        for k in range(n):
            z = z and tab[k][j]
        ans[i][j] = z
tr = True
for i in range(n):
    for j in range(m):
        z = 0
        for k in ans[i]:
            z = z or k
        for k in range(n):
            z = z or ans[k][j]
        if z != tab[i][j] and tr:
            tr = False
            print('NO')
if tr:
    print('YES')
    for s in ans:
        for x in s:
            print(x, end = ' ')
        print()


import operator

def mx_or(mx):
    n = len(mx)
    m = len(mx[0])
    result = [[0 for j in range(m)] for i in range(n)]
    for i in range(n):
        for j in range(m):
            if mx[i][j]:
                for k in range(n):
                    result[k][j] = 1
                for k in range(m):
                    result[i][k] = 1
    return result

none = lambda iterable: all(map(operator.not_, iterable))

n, m = list(map(int, input().split()))
mx = [[ ] for i in range(n)]

for i in range(n):
    mx[i] = list(map(int, input().split()))

result = [[1 for j in range(m)] for i in range(n)]

for i in range(n):
    for j in range(m):
        if not mx[i][j]:
            for k in range(n):
                result[k][j] = 0
            for k in range(m):
                result[i][k] = 0

if mx_or(result) == mx:
    print("YES")
    for i in range(n):
        print(' '.join(map(str, result[i])))
else:
    print("NO")


m, n = map(int, input().split())
B = [list(map(int, input().split())) for x in range(m)]
A = [[1 for x in range(n)] for x in range(m)]
#C = [[0 for x in range(n)] for x in range(m)]
for i in range(m):
    for j in range(n):
        if B[i][j] == 0:
            for y in range(m):
                A[y][j] = 0
            for z in range(n):
                A[i][z] = 0
for i in range(m):
    for j in range(n):
        tmp = 0
        for y in range(m):
            tmp = tmp | A[y][j]
        for z in range(n):
            tmp = tmp | A[i][z]
        if tmp != B[i][j]:
            print("NO")
            return
print("YES") 
for li in A:
    print(' '.join(map(str, li)))

from math import *

n, m = input().split()
n, m = int(n), int(m)

b = [[int(i) for i in input().split()] for i in range(n)]
a = [[1] * m for i in range(n)]
c = [[0] * m for i in range(n)]

for i in range(n):
    for j in range(m):
        if (b[i][j] == 0):
            for k in range(m):
                a[i][k] = 0
                
            for k in range(n):
                a[k][j] = 0
                
for i in range(n):
    for j in range(m):
        c[i][j] = 0
        
        for k in range(m):
            if (a[i][k] == 1):
                c[i][j] = 1
                break
                
        if (c[i][j] == 1):
            continue
            
        for k in range(n):
            if (a[k][j] == 1):
                c[i][j] = 1
                break
                
bad = False
                
for i in range(n):
    for j in range(m):
        if (c[i][j] != b[i][j]):
            bad = True
            print('NO')
            break
            
    if (bad):
        break

if (not bad):
    print('YES')
    
    for i in range(n):
        for j in range(m):
            print(a[i][j], end = ' ')
            
        print()

def ok( AA , resB ):
    realB = []
    for i in range(0,m):
        realBrow = []
        for j in range(0,n):
            res = 0
            for k in range(0,m):
                res += AA[k][j]
            for k in range(0,n):
                res += AA[i][k]
            if res > 0:
                res = 1
            realBrow.append( res )
        realB.append( realBrow )

    for i in range(0,m):
        for j in range(0,n):
            if realB[i][j] != resB[i][j]:
                return False
    return True

[m,n] = input().split(" ")
m = int(m)
n = int(n)
#print("m:%d n:%d" % ( m , n ) )

B = []
A = []
for i in range(0,m):
    brow = input().split(" ")
    arow = []
    for j in range(0,n):
        brow[j] = int(brow[j])
        arow.append(1)
    B.append( brow )
    A.append( arow )

#print(B)
for i in range(0,m):
    for j in range(0,n):
        if B[i][j] == 0:
            for k in range(0,m):
                A[k][j] = 0
            for k in range(0,n):
                A[i][k] = 0

if ok(A,B):
    print("YES")
    for i in range(0,m):
        for j in range(0,n):
            A[i][j] = str(A[i][j])
        print(" ".join(A[i]))
else:
    print("NO")





from functools import reduce

def foldM0(mat, n, m, f):
    ret = [x[:] for x in mat]
    for i in range(n):
        v = reduce(f, [mat[i][j] for j in range(m)])
        for j in range(m):
            ret[i][j] = v
    for i in range(m):
        v = reduce(f, [mat[j][i] for j in range(n)])
        for j in range(n):
            ret[j][i] = f(ret[j][i], v)
    return ret

    
def solve(mat, n, m):
    matpo = foldM0(mat, n, m, lambda x, y: x&y)
    if mat == foldM0(matpo, n, m, lambda x, y: x|y):
        print("YES")
        print("\n".join(" ".join(str(x) for x in xs) for xs in matpo))
    else:
        print("NO")

n, m = map(int, input().split())

mat = []
for i in range(n):
    mat.append(list(map(int, input().split())))
    
solve(mat, n, m)

a, b = list(map(int, input().split(' ')))
array = [[1] * b for i in range(a)]
orig = [list(map(int, input().split(' '))) for i in range(a)]
matrix = []
for i in orig:
    matrix.append(i[:])

row0 = []
col0 = []
for i in range(a):
    for j in range(b):
        if matrix[i][j] == 0:
            row0.append(i)
            col0.append(j)
            
row0 = list(set(row0))
col0 = list(set(col0))
for i in row0:
    matrix[i] = [0] * b
for ele in col0:
    for i in range(a):
        matrix[i][ele] = 0

match = [[0] * b for i in range(a)]
for i in range(len(matrix)):
    if 1 in matrix[i]:
        match[i] = [1] * len(matrix[0])

jlist = []
for i in range(a):
    for j in range(b):
        if matrix[i][j] == 1:
            jlist.append(j)
for i in jlist:
    for bad in range(len(match)):
        match[bad][i] = 1
if match == orig:
    print("YES")
    for i in matrix:
        print(' '.join([str(j) for j in i]))

else:
    print("NO")


n, m = [int(i) for i in input().split()]
sum1 = [0] * n
sum2 = [0] * m
res = [[0] * m for i in range(n)]
a = 0
k = [0] * 4
flag = False
for i in range(n):
    a = [int(i2) for i2 in input().split()]
    sum1[i] = sum(a)
    for i2 in range(m):
        sum2[i2] += a[i2]
for i in range(n):
    if sum1[i] == m:
        k[2] += 1
for i in range(m):
    if sum2[i] == n:
        k[3] += 1
for i in range(n):
    if (sum1[i] > k[3]) and not(sum1[i] == 0 or sum1[i] == m) or ((k[2] * k[3] == 0) and k[2] != k[3]):
        flag = True
for i in range(m):
    if (sum2[i] > k[2]) and not(sum2[i] == 0 or sum2[i] == n) or ((k[2] * k[3] == 0) and k[2] != k[3]):
        flag = True
if flag:
    print('NO')
else:
    print('YES')
    for i in range(n):
        for i2 in range(m):
            res[i][i2] = 1
    for i in range(m):
        if sum2[i] != n:
            for i2 in range(n):
                res[i2][i] = 0
    for i in range(n):
        if sum1[i] != m:
            for i2 in range(m):
                res[i][i2] = 0
    for i in range(n):
        for i2 in range(m):
            print(res[i][i2],end=' ')
        print()


m, n = (int(x) for x in input().split())
b = []
r1 = []
for i in range(m):
    b.append([int(x) for x in input().split()])
    r1.append(sum(b[i]) == n)
c1 = [sum(b[i][j] for i in range(m)) == m for j in range(n)]
if (sum(r1) == 0 and sum(c1)) != 0 or (sum(r1) != 0 and sum(c1) == 0):
    print('NO')
    return
a = []
for i in range(m):
    a.append([])
    for j in range(n):
        if b[i][j] == 0:
            a[i].append(0)
        elif not r1[i] and not c1[j]:
            print('NO')
            return
        else:
            a[i].append(1 if r1[i] and c1[j] else 0)
print('YES')
for i in range(m):
    print(' '.join(map(str, a[i])))

n, k = [int(x) for x in input().split()]
arr = []
ans = []
rows = [0] * n
cols = [0] * k
for i in range(n):
	arr.append(input().split())
	ans.append(['0'] * k)
	rows[i] = all([a == '1' for a in arr[-1]])
for i in range(k):
	sum = 0
	for j in range(n):
		sum += 1 if arr[j][i] == '1' else 0
	if sum == n:
		cols[i] = True
for i in range(n):
	for j in range(k):
		if ((arr[i][j] == '1' and not rows[i] and not cols[j]) or
                   (arr[i][j] == '0' and (rows[i] or cols[j]))):
			print('NO')
			return
if any(rows) ^ any(cols):
	print('NO')
	return
for i in range(n):
	if not rows[i]:
		continue
	for j in range(k):
		if cols[j]:
			ans[i][j] = '1'
print('YES')
print('\n'.join(' '.join(l) for l in ans))


def main():
    n, m = map(int, input().split())
    l = tuple(tuple(map(int, input().split())) for _ in range(n))
    res = [[1] * m for _ in range(n)]
    for y, row in enumerate(l):
        for x, f in enumerate(row):
            if not f:
                res[y] = [0] * m
                for rr in res:
                    rr[x] = 0
    for y, row in enumerate(l):
        for x, f in enumerate(row):
            if f:
                if not (any(res[y]) or any(rr[x] for rr in res)):
                    print('NO')
                    return
    print('YES')
    for rr in res:
        print(*rr)


def __starting_point():
    main()
__starting_point()