N,M=map(int,input().split())
A=[]
B=[]
def imap(MAP):
for _ in range(N):
MAP.append([int(x) for x in input().split()])
imap(A)
input()
imap(B)
C=[]
R=[]
for i in range(N):
R.append(sum(B[i]))
for j in range(M):
sume=0
for i in range(N):
sume+=B[i][j]
C.append(sume)
for i in range(N):
for j in range(M):
if (C[j]+R[i]-B[i][j])%2==1:
A[i][j]=1-A[i][j]
for i in A:
print(*i)