Ramesses came to university to algorithms practice, and his professor, who is a fairly known programmer, gave him the following task.

You are given two matrices $A$ and $B$ of size $n \times m$, each of which consists of $0$ and $1$ only. You can apply the following operation to the matrix $A$ arbitrary number of times: take any submatrix of the matrix $A$ that has at least two rows and two columns, and invert the values in its corners (i.e. all corners of the submatrix that contain $0$, will be replaced by $1$, and all corners of the submatrix that contain $1$, will be replaced by $0$). You have to answer whether you can obtain the matrix $B$ from the matrix $A$. [Image] An example of the operation. The chosen submatrix is shown in blue and yellow, its corners are shown in yellow. 

Ramesses don't want to perform these operations by himself, so he asks you to answer this question.

A submatrix of matrix $M$ is a matrix which consist of all elements which come from one of the rows with indices $x_1, x_1+1, \ldots, x_2$ of matrix $M$ and one of the columns with indices $y_1, y_1+1, \ldots, y_2$ of matrix $M$, where $x_1, x_2, y_1, y_2$ are the edge rows and columns of the submatrix. In other words, a submatrix is a set of elements of source matrix which form a solid rectangle (i.e. without holes) with sides parallel to the sides of the original matrix. The corners of the submatrix are cells $(x_1, y_1)$, $(x_1, y_2)$, $(x_2, y_1)$, $(x_2, y_2)$, where the cell $(i,j)$ denotes the cell on the intersection of the $i$-th row and the $j$-th column.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \leq n, m \leq 500$) — the number of rows and the number of columns in matrices $A$ and $B$.

Each of the next $n$ lines contain $m$ integers: the $j$-th integer in the $i$-th line is the $j$-th element of the $i$-th row of the matrix $A$ ($0 \leq A_{ij} \leq 1$). 

Each of the next $n$ lines contain $m$ integers: the $j$-th integer in the $i$-th line is the $j$-th element of the $i$-th row of the matrix $B$ ($0 \leq B_{ij} \leq 1$). 


-----Output-----

Print "Yes" (without quotes) if it is possible to transform the matrix $A$ to the matrix $B$ using the operations described above, and "No" (without quotes), if it is not possible. You can print each letter in any case (upper or lower).


-----Examples-----
Input
3 3
0 1 0
0 1 0
1 0 0
1 0 0
1 0 0
1 0 0

Output
Yes

Input
6 7
0 0 1 1 0 0 1
0 1 0 0 1 0 1
0 0 0 1 0 0 1
1 0 1 0 1 0 0
0 1 0 0 1 0 1
0 1 0 1 0 0 1
1 1 0 1 0 1 1
0 1 1 0 1 0 0
1 1 0 1 0 0 1
1 0 1 0 0 1 0
0 1 1 0 1 0 0
0 1 1 1 1 0 1

Output
Yes

Input
3 4
0 1 0 1
1 0 1 0
0 1 0 1
1 1 1 1
1 1 1 1
1 1 1 1

Output
No



-----Note-----

The examples are explained below. [Image] Example 1.  [Image] Example 2.  [Image] Example 3.

Difficulty: MEDIUM

Solutions:
(n, m) = map(int, input().split())
A = []
B = []
Acount = []
Bcount = []
for i in range(n):
	A.append(list(map(int, input().split())))
for i in range(n):
	B.append(list(map(int, input().split())))
for i in range(n):
	count = 0
	for j in range(m):
		if A[i][j] == 1:
			count += 1
	Acount.append(count)
for i in range(m):
	count = 0
	for j in range(n):
		if A[j][i] == 1:
			count += 1
	Acount.append(count)
for i in range(n):
	count = 0
	for j in range(m):
		if B[i][j] == 1:
			count += 1
	Bcount.append(count)
for i in range(m):
	count = 0
	for j in range(n):
		if B[j][i] == 1:
			count += 1
	Bcount.append(count)
flag = 1
for i in range(n + m):
	if (Acount[i] - Bcount[i]) % 2 == 1:
		flag = 0
if flag == 1:
	print('Yes')
else:
	print('No')


def flip(bit):
	if bit == 0:
		return 1
	else:
		return 0
(n, m) = map(int, input().split())
A = []
B = []
for i in range(n):
	A.append(list(map(int, input().split())))
for i in range(n):
	B.append(list(map(int, input().split())))
for i in range(n - 1):
	for j in range(m - 1):
		if A[i][j] != B[i][j]:
			A[i][j] = flip(A[i][j])
			A[i + 1][j] = flip(A[i + 1][j])
			A[i][j + 1] = flip(A[i][j + 1])
			A[i + 1][j + 1] = flip(A[i + 1][j + 1])
flag = 0
for i in range(n):
	for j in range(m):
		if A[i][j] != B[i][j]:
			print('No')
			flag = 1
			break
	if flag == 1:
		break
else:
	print('Yes')


(N, M) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
B = [list(map(int, input().split())) for i in range(N)]
if N == 1 or M == 1:
	print('Yes' if A == B else 'No')
	exit()
D = []
for (arow, brow) in zip(A, B):
	D.append([abs(a - b) for (a, b) in zip(arow, brow)])
for i in range(N - 1):
	ds = [j for j in range(M) if D[i][j]]
	if len(ds) % 2:
		print('No')
		exit()
	for j in ds:
		D[i + 1][j] = 1 - D[i + 1][j]
print('No' if any(D[-1]) else 'Yes')


def f(n, m, A, B):
	s_w_a = []
	s_w_b = []
	for i in range(n):
		s_w_a.append(0)
		s_w_b.append(0)
		for j in range(m):
			s_w_a[-1] += A[i][j]
			s_w_b[-1] += B[i][j]
	s_h_a = []
	s_h_b = []
	for i in range(m):
		s_h_a.append(0)
		s_h_b.append(0)
		for j in range(n):
			s_h_a[-1] += A[j][i]
			s_h_b[-1] += B[j][i]
	for i in range(len(s_w_a)):
		if (s_w_a[i] - s_w_b[i]) % 2 != 0:
			return 'No'
	for i in range(len(s_h_a)):
		if (s_h_a[i] - s_h_b[i]) % 2 != 0:
			return 'No'
	return 'Yes'
(n, m) = list(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(list(map(int, input().split())))
print(f(n, m, A, B))


(n, m) = [int(i) for i in input().split()]
A = []
for i in range(n):
	B = [int(j) for j in input().split()]
	A.append(B)
B = []
for i in range(n):
	C = [int(j) for j in input().split()]
	B.append(C)
changesx = []
changesy = []
for i in range(n):
	for j in range(m):
		if A[i][j] != B[i][j]:
			changesx.append(i)
			changesy.append(j)
from collections import defaultdict
ddx = defaultdict(int)
ddy = defaultdict(int)
for i in changesx:
	ddx[i] += 1
for i in changesy:
	ddy[i] += 1
ok = 1
for i in ddx:
	if ddx[i] % 2 != 0:
		ok = 0
for i in ddy:
	if ddy[i] % 2 != 0:
		ok = 0
if ok:
	print('Yes')
else:
	print('No')


def get_inp(nf):
	a = b = 0
	for _ in range(nf):
		inp = input()
		a ^= int(inp.replace(' ', ''), 2)
		b = b * 2 + inp.count('1') % 2
	return (a, b)
n = int(input().split()[0])
if get_inp(n) == get_inp(n):
	print('Yes')
else:
	print('No')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
ok = True
for i in range(n):
	c = 0
	for j in range(m):
		if a[i][j] != b[i][j]:
			c += 1
	if c & 1:
		ok &= False
		break
for j in range(m):
	c = 0
	for i in range(n):
		if a[i][j] != b[i][j]:
			c += 1
	if c & 1:
		ok &= False
		break
if ok:
	print('Yes')
else:
	print('No')


from math import gcd
from bisect import bisect_left
from collections import Counter
(n, m) = map(int, input().split())
a = []
b = []
c1 = Counter()
c2 = Counter()
for i in range(n):
	a.append(list(map(int, input().split())))
	c1.update(a[i])
for i in range(n):
	b.append(list(map(int, input().split())))
	c2.update(b[i])
if c1[1] % 2 != c2[1] % 2 or c1[0] % 2 != c2[0] % 2:
	print('No')
	quit()
del c1
del c2
for i in range(n):
	c1 = Counter(a[i])
	c2 = Counter(b[i])
	if c1[1] % 2 != c2[1] % 2 or c1[0] % 2 != c2[0] % 2:
		print('No')
		quit()
for i in range(m):
	c1 = []
	c2 = []
	for j in range(n):
		c1.append(a[j][i])
		c2.append(b[j][i])
	c1 = Counter(c1)
	c2 = Counter(c2)
	if c1[1] % 2 != c2[1] % 2 or c1[0] % 2 != c2[0] % 2:
		print('No')
		quit()
print('Yes')


def solve(n, m, a, b):
	(row_count_a, col_count_a) = ([0] * n, [0] * m)
	(row_count_b, col_count_b) = ([0] * n, [0] * m)
	for i in range(n):
		for j in range(m):
			if a[i][j] == '1':
				row_count_a[i] += 1
				col_count_a[j] += 1
			if b[i][j] == '1':
				row_count_b[i] += 1
				col_count_b[j] += 1
	return 'Yes' if all((abs(row_count_a[i] - row_count_b[i]) % 2 == 0 for i in range(n))) and all((abs(col_count_a[i] - col_count_b[i]) % 2 == 0 for i in range(m))) else 'No'
(n, m) = map(int, input().split())
a = [input().split() for _ in range(n)]
b = [input().split() for _ in range(n)]
print(solve(n, m, a, b))


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
s = [list(map(int, input().split())) for _ in range(n)]
d = [[], [], [], []]
for q in range(n):
	d[0].append(a[q].count(1))
for q in range(m):
	ans = 0
	for q1 in range(n):
		ans += a[q1][q]
	d[1].append(ans)
for q in range(n):
	d[2].append(s[q].count(1))
for q in range(m):
	ans = 0
	for q1 in range(n):
		ans += s[q1][q]
	d[3].append(ans)
if all((d[0][q] % 2 == d[2][q] % 2 for q in range(n))) and all((d[1][q] % 2 == d[3][q] % 2 for q in range(m))):
	print('Yes')
else:
	print('No')


mod = 10 ** 9 + 7
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
from random import randint as rn

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	(n, m) = cin()
	a = []
	b = []
	c = []
	d = []
	for i in range(n):
		l = ain()
		a.append(l)
		c.append([0] * m)
	for i in range(n):
		l = ain()
		b.append(l)
	for i in range(m):
		d.append([0] * n)
	for i in range(n):
		for j in range(m):
			c[i][j] = a[i][j] ^ b[i][j]
			d[j][i] = c[i][j]
	ans = 'Yes'
	for i in c:
		if sum(i) % 2 != 0:
			ans = 'No'
			break
	for i in d:
		if sum(i) % 2 != 0:
			ans = 'No'
			break
	print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(r, c) = [int(x) for x in input().split()]
(a, b) = ([], [])
for i in range(r):
	a.append([int(x) for x in input().split()])
for i in range(r):
	b.append([int(x) for x in input().split()])

def change(m, i, j):
	for (x, y) in [(0, 0), (1, 0), (0, 1), (1, 1)]:
		m[i + x][j + y] = 1 - m[i + x][j + y]
for i in range(r - 1):
	for j in range(c - 1):
		if a[i][j] != b[i][j]:
			change(a, i, j)
	if a[i][-1] != b[i][-1]:
		print('No')
		quit()
for j in range(c):
	if a[-1][j] != b[-1][j]:
		print('No')
		quit()
print('Yes')


(n, m) = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(n)]

def rev(i, j):
	A[i][j] ^= 1
	A[i + 1][j] ^= 1
	A[i][j + 1] ^= 1
	A[i + 1][j + 1] ^= 1
for i in range(n - 1):
	for j in range(m - 1):
		if A[i][j] != B[i][j]:
			rev(i, j)
if A == B:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
d = [list(map(lambda x, y: x ^ y, u, v)) for (u, v) in zip(a, b)]
p = any(map(lambda x: sum(x) & 1, d))
q = any(map(lambda x: sum(x) & 1, zip(*d)))
if p or q:
	print('No')
else:
	print('Yes')


def inp1():
	return int(input())

def inp2():
	return list(map(int, input().split()))

def inp3():
	return map(int, input().split())
if 1:
	(n, m) = inp3()
	a = []
	b = []
	c = 0
	for i in range(n):
		a.append(inp2())
	for i in range(n):
		b.append(inp2())
	f = 0
	ans = [[0] * m for i in range(n)]
	for i in range(n):
		for j in range(m):
			if a[i][j] != b[i][j]:
				ans[i][j] = 1
	a = [0] * m
	b = [0] * n
	for i in range(n):
		for j in range(m):
			a[j] += ans[i][j]
			b[i] += ans[i][j]
	for i in range(m):
		if a[i] % 2:
			f = 1
	for i in range(n):
		if b[i] % 2:
			f = 1
	if f:
		print('No')
	else:
		print('Yes')


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
asum = 0
bsum = 0
for i in range(n):
	alpha = sum(a[i])
	beta = sum(b[i])
	if alpha % 2 != beta % 2:
		print('No')
		exit()
	asum += alpha
	bsum += beta
if asum % 2 != bsum % 2:
	print('No')
	exit()
for j in range(m):
	alpha = 0
	beta = 0
	for i in range(n):
		alpha += a[i][j]
		beta += b[i][j]
	if alpha % 2 != beta % 2:
		print('No')
		exit()
print('Yes')


(n, m) = map(int, input().split())
a = [tuple(map(int, input().split())) for i in range(n)]
b = [tuple(map(int, input().split())) for i in range(n)]
diff = [[a[i][j] ^ b[i][j] for j in range(m)] for i in range(n)]
for line in diff:
	if line.count(1) & 1:
		print('No')
		exit()
for j in range(m):
	if [diff[i][j] for i in range(n)].count(1) & 1:
		print('No')
		exit()
print('Yes')


t = 1
for _ in range(t):
	(n, m) = map(int, input().split())
	mata = []
	matb = []
	for i in range(n):
		arr = [int(j) for j in input().split()]
		mata += [arr]
	for i in range(n):
		arr = [int(j) for j in input().split()]
		matb += [arr]
	flag = 0
	for i in range(n):
		cur = 0
		for j in range(m):
			if mata[i][j] != matb[i][j]:
				cur += 1
		if cur % 2 == 1:
			flag = 1
	for i in range(m):
		cur = 0
		for j in range(n):
			if mata[j][i] != matb[j][i]:
				cur += 1
		if cur % 2 == 1:
			flag = 1
	if flag == 1:
		print('No')
	else:
		print('Yes')


(n, m) = map(int, input().split())
mat1 = []
mat2 = []
for i in range(n):
	mat1.append(list(map(int, input().split())))
for i in range(n):
	mat2.append(list(map(int, input().split())))
flag = 1
for i in range(n):
	s1 = sum(mat1[i])
	s2 = sum(mat2[i])
	if s1 % 2 != s2 % 2:
		flag = 0
		break
for i in range(m):
	s1 = 0
	s2 = 0
	for j in range(n):
		s1 += mat1[j][i]
		s2 += mat2[j][i]
	if s1 % 2 != s2 % 2:
		flag = 0
		break
if flag:
	print('Yes')
else:
	print('No')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, m) = sep()
	a = []
	b = []
	for i in range(n):
		temp = lis()
		a.append(temp)
	for i in range(n):
		temp = lis()
		b.append(temp)
	for i in range(1, n):
		for j in range(1, m):
			if a[i][j] != b[i][j]:
				a[i][j] = b[i][j]
				a[i][0] = 1 - a[i][0]
				a[0][j] = 1 - a[0][j]
				a[0][0] = 1 - a[0][0]
	for j in range(m):
		if a[0][j] != b[0][j]:
			print('No')
			return
	for i in range(n):
		if a[i][0] != b[i][0]:
			print('No')
			return
	print('Yes')
testcase(1)


(n, m) = map(int, input().split())
a = [[0] * m for i in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	v = list(map(int, input().split()))
	for j in range(m):
		a[i][j] ^= v[j]
for i in range(n):
	for j in range(m):
		if a[i][j] == 1:
			k = j + 1
			while k < m and a[i][k] == 0:
				k += 1
			if k < m:
				z = i + 1
				while z < n and a[z][j] == 0:
					z += 1
				if z < n:
					(a[i][j], a[i][k], a[z][j], a[z][k]) = (0, 0, 0, 1 - a[z][k])
print('Yes' if max(max(a)) == 0 else 'No')


(n, m) = map(int, input().split())
A = [input().split() for _ in range(n)]
B = [input().split() for _ in range(n)]
C = [[A[i][j] != B[i][j] for j in range(m)] for i in range(n)]
f = True
for r in C:
	if sum(r) % 2:
		f = False
for c in range(m):
	if sum([C[r][c] for r in range(n)]) % 2:
		f = False
if f:
	print('Yes')
else:
	print('No')


(sizeI, sizeJ) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(sizeI)]
b = [list(map(int, input().split())) for _ in range(sizeI)]

def solve():
	for i in range(sizeI):
		parityA = a[i].count(1)
		parityB = b[i].count(1)
		if parityA & 1 != parityB & 1:
			return 'No'
	for j in range(sizeJ):
		parityA = parityB = 0
		for i in range(sizeI):
			parityA += a[i][j] == 1
			parityB += b[i][j] == 1
		if parityA & 1 != parityB & 1:
			return 'No'
	return 'Yes'
print(solve())


first = [int(i) for i in input().split(' ')]
n = first[0]
m = first[1]
A = []
B = []
for i in range(n):
	A.append([int(i) for i in input().split(' ')])
for i in range(n):
	B.append([int(i) for i in input().split(' ')])
diff = []
for i in range(n):
	tmp = []
	for j in range(m):
		if A[i][j] == B[i][j]:
			tmp.append(0)
		else:
			tmp.append(1)
	diff.append(tmp)

def invert(matrix, x1, y1, x2, y2):
	matrix[x1][y1] = 1 if matrix[x1][y1] == 0 else 0
	matrix[x1][y2] = 1 if matrix[x1][y2] == 0 else 0
	matrix[x2][y1] = 1 if matrix[x2][y1] == 0 else 0
	matrix[x2][y2] = 1 if matrix[x2][y2] == 0 else 0

def find(matrix, n, m, i, j):
	for x in range(i + 1, n):
		for y in range(j + 1, m):
			if matrix[x][y] == 1:
				return (x, y)
	return (-1, -1)

def check(diff, n, m):
	for i in range(n):
		for j in range(m):
			if diff[i][j] == 1:
				(x, y) = find(diff, n, m, i, j)
				if x == -1 and y == -1:
					return False
				invert(diff, i, j, x, y)
	return True
res = check(diff, n, m)
if res:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n - 1):
	for j in range(m - 1):
		if a[i][j] != b[i][j]:
			a[i][j] ^= 1
			a[i + 1][j] ^= 1
			a[i][j + 1] ^= 1
			a[i + 1][j + 1] ^= 1
ans = True
for i in range(n):
	for j in range(m):
		if a[i][j] != b[i][j]:
			ans = False
if ans == True:
	print('Yes')
else:
	print('No')


(n, k) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
flag = 0
for i in range(n):
	r = 0
	for j in range(k):
		if a[i][j] != b[i][j]:
			r += 1
	if r % 2 == 1:
		flag = 1
		break
for i in range(k):
	c = 0
	for j in range(n):
		if a[j][i] != b[j][i]:
			c += 1
	if c % 2 == 1:
		flag = 1
		break
if flag == 1:
	print('No')
else:
	print('Yes')


R = lambda : map(int, input().split())
(n, m) = R()
(A, B) = ([], [])
for i in range(n):
	A.append(list(R()))
for i in range(n):
	B.append(list(R()))
if n == 1 or m == 1:
	if A == B:
		print('Yes')
	else:
		print('No')
	quit()
for i in range(n - 1):
	for j in range(m - 1):
		if A[i][j] != B[i][j]:
			A[i][j] ^= 1
			A[i + 1][j] ^= 1
			A[i][j + 1] ^= 1
			A[i + 1][j + 1] ^= 1
if A == B:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
A1 = [list(map(int, input().split())) for i in range(n)]
A2 = [list(map(int, input().split())) for wi in range(n)]
for i in range(n):
	if A1[i].count(0) % 2 != A2[i].count(0) % 2:
		print('No')
		return
for j in range(m):
	z1 = 0
	z2 = 0
	for i in range(n):
		if A1[i][j] == 0:
			z1 += 1
		if A2[i][j] == 0:
			z2 += 1
	if z1 % 2 != z2 % 2:
		print('No')
		return
print('Yes')


(n, m) = [int(x) for x in input().split()]
(a, b) = ([], [])
for i in range(n):
	a.append([int(x) for x in input().split()])
for i in range(n):
	b.append([int(x) for x in input().split()])
flag = 0
for i in range(n):
	cnt = 0
	for j in range(m):
		if a[i][j] != b[i][j]:
			cnt += 1
	if cnt % 2 != 0:
		flag = 1
		break
for i in range(m):
	cnt = 0
	for j in range(n):
		if a[j][i] != b[j][i]:
			cnt += 1
	if cnt % 2 != 0:
		flag = 1
		break
if flag:
	print('No')
else:
	print('Yes')


import sys
(n, m) = [int(s) for s in input().split()]
array_1 = []
for i in range(n):
	array_1.append([int(s) for s in input().split()])
array_2 = []
for i in range(n):
	array_2.append([int(s) for s in input().split()])
for i in range(n):
	if sum(array_1[i]) % 2 != sum(array_2[i]) % 2:
		print('No')
		sys.exit(0)
for j in range(m):
	sum_1 = 0
	sum_2 = 0
	for i in range(n):
		sum_1 += array_1[i][j]
		sum_2 += array_2[i][j]
	if sum_1 % 2 != sum_2 % 2:
		print('No')
		sys.exit(0)
print('Yes')


import math
import bisect
import heapq

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
(n, m) = f(1)
r1 = [0] * n
r2 = [0] * n
c1 = [0] * m
c2 = [0] * m
m1 = []
m2 = []
for i in range(n):
	m1.append(f(2))
for i in range(n):
	m2.append(f(2))
for i in range(n):
	for j in range(m):
		r1[i] += m1[i][j]
		r2[i] += m2[i][j]
		c1[j] += m1[i][j]
		c2[j] += m2[i][j]
for i in range(n):
	r1[i] = r1[i] % 2
	r2[i] = r2[i] % 2
for j in range(m):
	c1[j] = c1[j] % 2
	c2[j] = c2[j] % 2
if c1 == c2 and r1 == r2:
	print('Yes')
else:
	print('No')


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

def solve(d):
	for i in range(n):
		if sum(d[i]) % 2 != 0:
			return False
	for j in range(m):
		if sum([d[i][j] for i in range(n)]) % 2 != 0:
			return False
	return True
a = []
b = []
for i in range(n):
	a.append([int(s) for s in input().split()])
for i in range(n):
	b.append([int(s) for s in input().split()])
d = []
for i in range(n):
	d.append([a[i][j] ^ b[i][j] for j in range(m)])
ans = solve(d)
if ans:
	print('Yes')
else:
	print('No')


def Solve(A, B, n, m):
	for i in range(n - 1):
		for j in range(m - 1):
			if A[i][j] != B[i][j]:
				A[i][j] = int(not A[i][j])
				A[i][j + 1] = int(not A[i][j + 1])
				A[i + 1][j] = int(not A[i + 1][j])
				A[i + 1][j + 1] = int(not A[i + 1][j + 1])
	for i in range(n):
		for j in range(m):
			if A[i][j] != B[i][j]:
				print('No')
				return
	print('Yes')

def main():
	(n, m) = list(map(int, input().split()))
	A = []
	B = []
	for i in range(n):
		A.append(list(map(int, input().split())))
	for i in range(n):
		B.append(list(map(int, input().split())))
	Solve(A, B, n, m)
main()


def g(f):
	a = b = 0
	for _ in range(f):
		i = input()
		(a, b) = (a ^ int(i.replace(' ', ''), 2), b * 2 + i.count('1') % 2)
	return (a, b)
n = int(input().split()[0])
print('Yes' if g(n) == g(n) else 'No')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
grid = []
ansGrid = []
for i in range(n):
	grid.append(list(map(int, input().split())))
for i in range(n):
	ansGrid.append(list(map(int, input().split())))
for i in range(n - 1):
	for j in range(m - 1):
		if grid[i][j] != ansGrid[i][j]:
			grid[i][j] ^= 1
			grid[i + 1][j] ^= 1
			grid[i][j + 1] ^= 1
			grid[i + 1][j + 1] ^= 1
valid = True
for i in range(n):
	if grid[i][m - 1] != ansGrid[i][m - 1]:
		valid = False
		break
for j in range(m):
	if grid[n - 1][j] != ansGrid[n - 1][j]:
		valid = False
		break
print('Yes' if valid else 'No')


line = [int(x) for x in input().split()]
n = line[0]
m = line[1]
mat = [[] for _ in range(n)]
target = [[] for _ in range(n)]
correct = True
for i in range(2 * n):
	l = [int(x) for x in input().split(' ')]
	if i < n:
		mat[i] = l
	else:
		target[i - n] = l
for i in range(n):
	m_par = sum(mat[i]) % 2
	t_par = sum(target[i]) % 2
	if m_par != t_par:
		correct = False
		break
mT = list(zip(*mat))
tT = list(zip(*target))
for i in range(m):
	m_par = sum(mT[i]) % 2
	t_par = sum(tT[i]) % 2
	if m_par != t_par:
		correct = False
		break
if correct:
	print('Yes')
else:
	print('No')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return tuple(map(int, sys.stdin.readline().split()))

def LLI():
	return [tuple(map(int, l.split())) for l in sys.stdin]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	a = [LI() for _ in range(n)]
	b = [LI() for _ in range(n)]
	for i in range(n):
		t = 0
		for j in range(m):
			if a[i][j] != b[i][j]:
				t += 1
		if t % 2 == 1:
			return 'No'
	for j in range(m):
		t = 0
		for i in range(n):
			if a[i][j] != b[i][j]:
				t += 1
		if t % 2 == 1:
			return 'No'
	return 'Yes'
print(main())


import sys
stdout = sys.stdout
rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : list(map(int, rr().split()))

def solve(R, C, A, B):
	for r in range(R):
		for c in range(C):
			A[r][c] ^= B[r][c]
	return all((sum(row) % 2 == 0 for row in A)) and all((sum(col) % 2 == 0 for col in zip(*A)))
(R, C) = rrm()
A = [rrm() for _ in range(R)]
B = [rrm() for _ in range(R)]
print('Yes' if solve(R, C, A, B) else 'No')


from sys import stdin

def solve():
	(N, M) = map(int, stdin.readline().split())
	A = []
	for _ in range(N):
		A.append([int(k) for k in stdin.readline().split()])
	c_diff = [0] * N
	r_diff = [0] * M
	for i in range(N):
		col = [int(k) for k in stdin.readline().split()]
		for j in range(M):
			if A[i][j] != col[j]:
				c_diff[i] += 1
				r_diff[j] += 1
	s = set(c_diff)
	ans = 'Yes'
	for x in s:
		if x % 2:
			ans = 'No'
			break
	if ans == 'Yes':
		s = set(r_diff)
		for x in s:
			if x % 2:
				ans = 'No'
				break
	print(ans)
solve()


R = lambda : map(int, input().split())
(n, m) = R()
(r, c) = ([0] * n, [0] * m)
a = [list(R()) for i in range(n)]
b = [list(R()) for i in range(n)]
for i in range(n):
	for j in range(m):
		if a[i][j] != b[i][j]:
			r[i] += 1
			c[j] += 1
for i in c:
	if i % 2 != 0:
		print('No')
		exit()
for i in r:
	if i % 2 != 0:
		print('No')
		exit()
print('Yes')


(n, m) = map(int, input().split())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
a = [0 for _ in range(m)]
b = [0 for j in range(n)]
for i in range(n):
	brr = list(map(int, input().split()))
	for j in range(len(brr)):
		if arr[i][j] != brr[j]:
			a[j] += 1
			b[i] += 1
f = 1
for i in range(len(a)):
	if a[i] % 2:
		f = 0
for j in range(len(b)):
	if b[j] % 2:
		f = 0
print(['No', 'Yes'][f])


(n, m) = [int(i) for i in input().split()]
a = []
b = []
for i in range(n):
	cor = [int(i) for i in input().split()]
	a.append(cor)
for i in range(n):
	cor = [int(i) for i in input().split()]
	b.append(cor)
row = [0] * n
col = [0] * m
for i in range(n):
	for j in range(m):
		if a[i][j] != b[i][j]:
			row[i] += 1
			col[j] += 1
ispos = 0
for i in row:
	if i % 2 != 0:
		ispos = 1
		break
for i in col:
	if i % 2 != 0:
		ispos = 1
		break
if ispos == 0:
	print('Yes')
else:
	print('No')


(N, M) = list(map(int, input().split()))
A = [[int(a) for a in input().split()] for i in range(N)]
B = [[int(a) for a in input().split()] for i in range(N)]
C = [[A[i][j] ^ B[i][j] for j in range(M)] for i in range(N)]
for i in range(N):
	if sum(C[i]) % 2:
		print('No')
		break
	if i < N - 1:
		for j in range(M):
			C[i + 1][j] ^= C[i][j]
else:
	if sum(C[N - 1]) == 0:
		print('Yes')
	else:
		print('No')


import math

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	vr = [int(x) for x in input().split()]
	a.append(vr)
for i in range(n):
	vr = [int(x) for x in input().split()]
	b.append(vr)
c = [[a[i][j] ^ b[i][j] for j in range(m)] for i in range(n)]
for i in range(n):
	if sum(c[i]) % 2:
		print('No')
		break
	if i < n - 1:
		for j in range(m):
			c[i + 1][j] ^= c[i][j]
else:
	if sum(c[n - 1]) == 0:
		print('Yes')
	else:
		print('No')


temparr = input()
temparr = temparr.split()
row = int(temparr[0])
col = int(temparr[1])
prevarr = []
for i in range(row):
	temparr = input()
	temparr = temparr.split()
	arr = []
	for i in temparr:
		arr.append(int(i))
	prevarr.append(arr[:])
curarr = []
for i in range(row):
	temparr = input()
	temparr = temparr.split()
	arr = []
	for i in temparr:
		arr.append(int(i))
	curarr.append(arr[:])
rowdiff = []
coldiff = []
for i in range(row):
	count = 0
	for j in range(col):
		if prevarr[i][j] != curarr[i][j]:
			count += 1
	rowdiff.append(count)
for i in range(col):
	count = 0
	for j in range(row):
		if prevarr[j][i] != curarr[j][i]:
			count += 1
	coldiff.append(count)
flag = 0
for i in rowdiff:
	if i & 1 == 1:
		flag = 1
for i in coldiff:
	if i & 1 == 1:
		flag = 1
if flag == 1:
	print('No')
else:
	print('Yes')


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

def is_similar(A, B, n, m):
	C = [[0 for i in range(m)] for i in range(n)]
	cnt_err = 0
	for i in range(n):
		for j in range(m):
			if A[i][j] != B[i][j]:
				C[i][j] = 1
				cnt_err += 1
	for i in range(n):
		cnt = 0
		for j in range(m):
			cnt += C[i][j]
		if cnt % 2 == 1:
			return print('No')
	for j in range(m):
		cnt = 0
		for i in range(n):
			cnt += C[i][j]
		if cnt % 2 == 1:
			return print('No')
	return print('Yes')
is_similar(A, B, n, m)


def main():
	(n, m) = map(int, input().split())
	(a, b) = ([], [])
	for i in range(n):
		a.append(list(map(int, input().split())))
	for i in range(n):
		b.append(list(map(int, input().split())))
	for i in range(n - 1):
		for j in range(m - 1):
			if a[i][j] != b[i][j]:
				a[i][j] = 1 - a[i][j]
				a[i + 1][j] = 1 - a[i + 1][j]
				a[i][j + 1] = 1 - a[i][j + 1]
				a[i + 1][j + 1] = 1 - a[i + 1][j + 1]
	for i in range(n):
		for j in range(m):
			if a[i][j] != b[i][j]:
				print('No')
				return
	print('Yes')

def __starting_point():
	main()
__starting_point()


from collections import defaultdict as dd
import math
import heapq

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return list(map(int, input().split()))

def lm():
	return list(map(int, input().split()))
(n, m) = mi()
A = []
for i in range(n):
	A.append(lm())
B = []
for i in range(n):
	B.append(lm())

def check(A, B):
	for i in range(n):
		count = 0
		for j in range(m):
			count += abs(A[i][j] - B[i][j])
		if not count % 2 == 0:
			return 'No'
	for j in range(m):
		count = 0
		for i in range(n):
			count += abs(A[i][j] - B[i][j])
		if not count % 2 == 0:
			return 'No'
	return 'Yes'
print(check(A, B))


def main():
	(n, m) = list(map(int, input().split()))
	A = [[0] * m for _ in range(n)]
	B = [[0] * m for _ in range(n)]
	for i in range(n):
		A[i] = list(map(int, input().split()))
	for i in range(n):
		B[i] = list(map(int, input().split()))
	for i in range(n):
		ans = 0
		for j in range(m):
			ans = ans + A[i][j] - B[i][j]
		if ans % 2 != 0:
			print('No')
			return
	for j in range(m):
		ans = 0
		for i in range(n):
			ans = ans + A[i][j] - B[i][j]
		if ans % 2 != 0:
			print('No')
			return
	print('Yes')
main()


(N, M) = map(int, input().split())
A = []
B = []
for i in range(N):
	A.append(list(map(int, input().split())))
for i in range(N):
	B.append(list(map(int, input().split())))
C = []
for i in range(N):
	tmp = []
	for j in range(M):
		a = A[i][j]
		b = B[i][j]
		tmp.append(a ^ b)
	C.append(tmp)
for i in range(N - 1):
	for j in range(M - 1):
		if C[i][j] == 0:
			continue
		else:
			C[i][j] = 0
			C[i + 1][j] = 1 if C[i + 1][j] == 0 else 0
			C[i][j + 1] = 1 if C[i][j + 1] == 0 else 0
			C[i + 1][j + 1] = 1 if C[i + 1][j + 1] == 0 else 0
for i in range(N):
	for j in range(M):
		c = C[i][j]
		if c == 1:
			print('No')
			exit()
print('Yes')


(a, b) = map(int, input().split())
A = []
B = [] * b
for i in range(a):
	A.append(list(map(int, input().split())))
	if i == 0:
		for j in range(b):
			B.append([A[i][j]])
	else:
		for j in range(b):
			B[j].append(A[i][j])
C = []
D = [] * b
for i in range(a):
	C.append(list(map(int, input().split())))
	if i == 0:
		for j in range(b):
			D.append([C[i][j]])
	else:
		for j in range(b):
			D[j].append(C[i][j])
k = True
for i in range(a):
	if sum(A[i]) % 2 != sum(C[i]) % 2:
		k = False
for i in range(b):
	if sum(B[i]) % 2 != sum(D[i]) % 2:
		k = False
q = 0
w = 0
for i in range(a):
	q += sum(A[i])
	w += sum(C[i])
if q % 2 != w % 2:
	k = False
if k == True:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
A = []
B = []
for i in range(n):
	A.append(list(map(int, input().split())))
for i in range(n):
	B.append(list(map(int, input().split())))
v = True
for r in range(n - 1):
	for c in range(m - 1):
		if A[r][c] != B[r][c]:
			A[r][c] ^= 1
			A[r + 1][c] ^= 1
			A[r][c + 1] ^= 1
			A[r + 1][c + 1] ^= 1
	if A[r][m - 1] != B[r][m - 1]:
		v = False
if A[n - 1] != B[n - 1]:
	v = False
if v == True:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
mat1 = []
for i in range(n):
	mat1.append([int(i) for i in input().split()])
mat2 = []
for i in range(n):
	mat2.append([int(i) for i in input().split()])
par1 = [0] * n
par2 = [0] * n
for i in range(n):
	p = 0
	p1 = 0
	for j in range(m):
		p ^= mat1[i][j]
		p1 ^= mat2[i][j]
	par2[i] = p1
	par1[i] = p
f = 1
if par1 != par2:
	f = 0
par1 = [0] * m
par2 = [0] * m
for j in range(m):
	for i in range(n):
		p ^= mat1[i][j]
		p1 ^= mat2[i][j]
	par2[j] = p1
	par1[j] = p
if par1 != par2:
	f = 0
print('Yes' if f else 'No')


(n, m) = map(int, input().split())
A = [0] * n
for i in range(n):
	A[i] = list(map(int, input().split()))
B = [0] * n
for i in range(n):
	B[i] = list(map(int, input().split()))
Arows = [sum(A[i]) % 2 for i in range(n)]
Acols = [sum((A[j][i] for j in range(n))) % 2 for i in range(m)]
Brows = [sum(B[i]) % 2 for i in range(n)]
Bcols = [sum((B[j][i] for j in range(n))) % 2 for i in range(m)]
if Arows == Brows and Acols == Bcols:
	print('Yes')
else:
	print('No')


(n, m) = [int(item) for item in input().split()]
a = []
b = []
for _ in range(n):
	a.append([int(item) for item in input().split()])
for _ in range(n):
	b.append([int(item) for item in input().split()])
ok = True
for i in range(n):
	c = 0
	for j in range(m):
		if a[i][j] != b[i][j]:
			c += 1
	if c & 1:
		ok &= False
		break
for j in range(m):
	c = 0
	for i in range(n):
		if a[i][j] != b[i][j]:
			c += 1
	if c & 1:
		ok &= False
		break
print('Yes' if ok else 'No')


(n, m) = map(int, input().split())
mat1 = []
mat2 = []
sum1 = 0
sum2 = 0
for i in range(n):
	a = list(map(int, input().split()))
	mat1.append(a)
for i in range(n):
	a = list(map(int, input().split()))
	mat2.append(a)
for i in range(n - 1):
	for j in range(m - 1):
		if mat1[i][j] != mat2[i][j]:
			mat1[i][j] = 1 - mat1[i][j]
			if j + 1 < m:
				mat1[i][j + 1] = 1 - mat1[i][j + 1]
			if i + 1 < n:
				mat1[i + 1][j] = 1 - mat1[i + 1][j]
			if i + 1 < n and j + 1 < m:
				mat1[i + 1][j + 1] = 1 - mat1[i + 1][j + 1]
if mat1 == mat2:
	print('Yes')
else:
	print('No')


SS = input()
SS = SS.strip().split(' ')
(N, M) = (int(SS[0]), int(SS[1]))
(mat1, mat2) = ([], [])
for i in range(N):
	SSS = input()
	line = SSS.strip().split(' ')
	line = list(map(int, line))
	mat1.append(line)
for i in range(N):
	SSS = input()
	line = SSS.strip().split(' ')
	line = list(map(int, line))
	mat2.append(line)
for i in range(N):
	for j in range(M):
		mat1[i][j] = mat1[i][j] ^ mat2[i][j]
ans = 'Yes'
for i in range(N):
	if sum(mat1[i]) % 2 == 1:
		ans = 'No'
for j in range(M):
	sum1 = 0
	for i in range(N):
		sum1 += mat1[i][j]
	if sum1 % 2 == 1:
		ans = 'No'
print(ans)


def main():
	(n, m) = map(int, input().split())
	arr = [list(map(int, input().split())) for _ in range(n)]
	kek = [list(map(int, input().split())) for _ in range(n)]
	for i in range(n):
		for j in range(m):
			arr[i][j] ^= kek[i][j]
	f = 1
	for i in range(n):
		s = 0
		for j in range(m):
			s += arr[i][j]
		if s & 1:
			f = 0
			break
	for i in range(m):
		s = 0
		for j in range(n):
			s += arr[j][i]
		if s & 1:
			f = 0
			break
	if f:
		print('Yes')
	else:
		print('No')
	return 0
main()


(N, M) = map(int, input().split())
A = []
B = []
for i in range(N):
	A.append(list(map(int, input().split())))
for i in range(N):
	B.append(list(map(int, input().split())))
a_row = 0
b_row = 0
for i in range(N):
	a_row = sum(A[i])
	b_row = sum(B[i])
	if a_row % 2 == b_row % 2:
		a_row = 0
		b_row = 0
		continue
	else:
		print('No')
		exit()
a_column = 0
b_column = 0
for j in range(M):
	for i in range(N):
		a_column += A[i][j]
		b_column += B[i][j]
	if a_column % 2 == b_column % 2:
		a_column = 0
		b_column = 0
		continue
	else:
		print('No')
		exit()
print('Yes')


(n, m) = map(int, input().split())
A = [[int(x) for x in input().split()] for _ in range(n)]
B = [[int(x) for x in input().split()] for _ in range(n)]
for i in range(n - 1):
	for j in range(m - 1):
		if A[i][j] != B[i][j]:
			A[i][j] = 1 - A[i][j]
			A[i + 1][j] = 1 - A[i + 1][j]
			A[i][j + 1] = 1 - A[i][j + 1]
			A[i + 1][j + 1] = 1 - A[i + 1][j + 1]
if A == B:
	print('Yes')
else:
	print('No')


mn = input().split()
n = int(mn[0])
m = int(mn[1])
f = 0
A = []
B = []

def del2(ls):
	if ls.count('1') % 2 == 0:
		return 1
	else:
		return 0
for i in range(n):
	A.append(input().split())
for i in range(n):
	B.append(input().split())
for i in range(0, n):
	if del2(A[i]) != del2(B[i]):
		f += 1
		break
if f > 0:
	print('No')
else:
	for j in range(m):
		st = []
		kz = []
		for i in range(n):
			st.append(A[i][j])
			kz.append(B[i][j])
		if del2(st) != del2(kz):
			f += 1
			break
	if f > 0:
		print('No')
	else:
		print('Yes')


(n, m) = map(int, input().split())
A = []
B = []
for i in range(n):
	A.append([int(x) for x in input().split()])
for i in range(n):
	B.append([int(x) for x in input().split()])
for i in range(n):
	for j in range(m):
		if A[i][j] != B[i][j]:
			state = 0
			mi = mj = 0
			for mi in range(i + 1, n):
				if A[mi][j] != B[mi][j]:
					A[mi][j] = B[mi][j]
					state += 1
					break
			for mj in range(j + 1, m):
				if A[i][mj] != B[i][mj]:
					A[i][mj] = B[i][mj]
					state += 1
					break
			if A[mi][mj]:
				A[mi][mj] = 0
			else:
				A[mi][mj] = 1
			if state != 2:
				print('No')
				exit()
print('Yes')


(R, C) = map(int, input().split())
(r, c) = ([0] * R, [0] * C)
a = [input().split() for i in r]
b = [input().split() for i in r]
for i in range(C):
	for j in range(R):
		r[j] += a[j][i] != b[j][i]
		c[i] += a[j][i] != b[j][i]
for C in c:
	if C % 2:
		print('No')
		exit()
for R in r:
	if R % 2:
		print('No')
		exit()
print('Yes')


from sys import stdin
input = stdin.readline

def check_parity(n):
	(a, b) = (0, 0)
	for i in range(n):
		line = input()
		a ^= int(line.replace(' ', ''), 2)
		b = b * 2 + line.count('1') % 2
	return (a, b)
(n, m) = map(int, input().split())
if check_parity(n) == check_parity(n):
	print('Yes')
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(list(map(int, input().split())))
flag = True
for i in range(n):
	hor = 0
	for l in range(m):
		if a[i][l] != b[i][l]:
			hor += 1
	if hor % 2 == 1:
		flag = False
		break
for l in range(m):
	hor = 0
	for i in range(n):
		if a[i][l] != b[i][l]:
			hor += 1
	if hor % 2 == 1:
		flag = False
		break
if flag:
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
g = 0
(total1, total2) = (0, 0)
for i in range(n):
	total1 += sum(a[i])
	total2 += sum(b[i])
	if sum(a[i]) & 1 != sum(b[i]) & 1:
		g = 1
		break
for i in range(m):
	(s1, s2) = (0, 0)
	for j in range(n):
		s1 += a[j][i]
		s2 += b[j][i]
	total1 += s1
	total2 += s2
	if s2 & 1 != s1 & 1:
		g = 1
		break
if total1 & 1 != total2 & 1:
	g = 1
if g:
	print('No')
else:
	print('Yes')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
c = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
	for j in range(m):
		if a[i][j] == b[i][j]:
			c[i][j] = 0
		else:
			c[i][j] = 1
row = [0 for j in range(m)]
col = [0 for i in range(n)]
for i in range(n):
	for j in range(m):
		row[j] += c[i][j]
		col[i] += c[i][j]
for i in row:
	if i % 2 == 1:
		print('No')
		exit()
for i in col:
	if i % 2 == 1:
		print('No')
		exit()
print('Yes')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import *
from operator import itemgetter, attrgetter
import bisect
import math
import heapq as hq
(n, m) = map(int, input().split())
first = []
second = []
for i in range(n):
	first.append(list(map(int, input().split())))
for i in range(n):
	second.append(list(map(int, input().split())))
temp = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	for j in range(m):
		if first[i][j] != second[i][j]:
			temp[i][j] = 1
vert = [0 for i in range(n)]
hor = [0 for i in range(m)]
for i in range(n):
	for j in range(m):
		if temp[i][j] == 1:
			vert[i] += 1
			hor[j] += 1
f = 0
for i in range(n):
	if vert[i] % 2:
		print('No')
		break
else:
	for i in range(m):
		if hor[i] % 2:
			print('No')
			break
	else:
		print('Yes')


(n, m) = map(int, input().split())
ar = [0 for i in range(n)]
br = [0 for i in range(n)]
ac = [0 for i in range(m)]
bc = [0 for i in range(m)]
for i in range(n):
	line = list(map(int, input().split()))
	for j in range(m):
		ar[i] ^= line[j]
		ac[j] ^= line[j]
for i in range(n):
	line = list(map(int, input().split()))
	for j in range(m):
		br[i] ^= line[j]
		bc[j] ^= line[j]
if ar != br:
	print('No')
elif ac != bc:
	print('No')
else:
	print('Yes')


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
s = [list(map(int, stdin.readline().strip().split())) for i in range(n)]
s1 = [list(map(int, stdin.readline().strip().split())) for i in range(n)]
col = [0 for i in range(m)]
row = [0 for i in range(n)]
for i in range(n):
	for j in range(m):
		if s[i][j] != s1[i][j]:
			col[j] += 1
			row[i] += 1
flag = 'Yes'
for i in range(m):
	if col[i] % 2 != 0:
		flag = 'No'
for i in range(n):
	if row[i] % 2 != 0:
		flag = 'No'
print(flag)


from collections import defaultdict
(n, m) = list(map(int, input().split()))
m1 = [list(input().split()) for _ in range(n)]
m2 = [list(input().split()) for _ in range(n)]
row_change = defaultdict(int)
col_change = defaultdict(int)
count_change = 0
for x in range(n):
	for y in range(m):
		if m1[x][y] != m2[x][y]:
			count_change += 1
			row_change[x] += 1
			col_change[y] += 1
if count_change % 2:
	print('No')
	return
if all((v % 2 == 0 for (k, v) in list(row_change.items()))) and all((v % 2 == 0 for (k, v) in list(col_change.items()))):
	print('Yes')
	return
print('No')


def mp():
	return map(int, input().split())
(n, m) = mp()
a = [list(mp()) for i in range(n)]
b = [list(mp()) for i in range(n)]
c = [[0] * m for i in range(n)]
for i in range(n):
	for j in range(m):
		if a[i][j] == b[i][j]:
			c[i][j] = 1
for i in range(n):
	for j in range(m):
		if c[i][j] == 1:
			continue
		k = h = -1
		for q in range(i + 1, n):
			if c[q][j] == 0:
				k = q
		for q in range(j + 1, m):
			if c[i][q] == 0:
				h = q
		c[i][j] = 1 - c[i][j]
		c[k][j] = 1 - c[k][j]
		c[i][h] = 1 - c[i][h]
		c[k][h] = 1 - c[k][h]
fail = 0
for i in range(n):
	for j in range(m):
		if c[i][j] == 0:
			fail = 1
			break
	if fail:
		print('No')
		break
else:
	print('Yes')


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
MOD = pow(10, 9) + 7

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
(n, m) = IN()
a = []
b = []
c = []
for i in range(n):
	rr = IN()
	a.append(rr)
	c.append(rr)
for i in range(n):
	b.append(IN())
fr = [0 for i in range(n)]
fc = [0 for i in range(m)]
for i in range(n):
	for j in range(m):
		if c[i][j] == b[i][j]:
			c[i][j] = 0
		else:
			c[i][j] = 1
			fr[i] += 1
			fc[j] += 1
f = 'Yes'
for i in fr:
	if i % 2 != 0:
		f = 'No'
		break
for i in fc:
	if i % 2 != 0:
		f = 'No'
		break
print(f)


class Solution:

	def __solve__(self):
		n = self[0]
		m = self[1]
		left = self[2]
		right = self[3]
		row = []
		column = []
		for i in range(n):
			row.append(0)
		for i in range(m):
			column.append(0)
		for i in range(n * m):
			h = int(i / m)
			l = i % m
			row[h] ^= left[0][i]
			column[l] ^= left[0][i]
		for i in range(n * m):
			h = int(i / m)
			l = i % m
			row[h] ^= right[0][i]
			column[l] ^= right[0][i]
		for i in range(n):
			if row[i] != 0:
				print('No')
				return
		for i in range(m):
			if column[i] != 0:
				print('No')
				return
		print('Yes')
		return

	def __read__():
		data = []
		first = input().split()
		n = int(first[0])
		m = int(first[1])
		data.append(n)
		data.append(m)
		left = [[]] * n
		right = [[]] * n
		for i in range(n):
			matix = input().split()
			for j in range(m):
				left[i].append(int(matix[j]))
		for i in range(n):
			matix = input().split()
			for j in range(m):
				right[i].append(int(matix[j]))
		data.append(left)
		data.append(right)
		return data
Solution.__solve__(Solution.__read__())


(n, m) = map(int, input().split())
A = []
B = []
for _ in range(n):
	row = list(map(int, input().split()))
	A.append(row)
for _ in range(n):
	row = list(map(int, input().split()))
	B.append(row)
flag = 0
for i in range(n):
	re = 0
	for j in range(m):
		if A[i][j] != B[i][j]:
			re += 1
	if re % 2 == 1:
		flag = 1
		break
if flag == 1:
	print('No')
else:
	for i in range(m):
		ce = 0
		for j in range(n):
			if A[j][i] != B[j][i]:
				ce += 1
		if ce % 2 == 1:
			flag = 1
			break
	if flag == 1:
		print('No')
	else:
		print('Yes')


(n, h) = [int(x) for x in input().strip().split(' ')]
max1 = []
max2 = []
for _ in range(n):
	max1.append([int(x) for x in input().strip().split(' ')])
for _ in range(n):
	max2.append([int(x) for x in input().strip().split(' ')])
for i in range(n):
	column_mis = 0
	for j in range(h):
		if max1[i][j] != max2[i][j]:
			column_mis += 1
	if column_mis % 2:
		print('No')
		exit()
for i in range(h):
	row_mis = 0
	for j in range(n):
		if max1[j][i] != max2[j][i]:
			row_mis += 1
	if row_mis % 2:
		print('No')
		exit()
print('Yes')


import sys, math, queue
sys.setrecursionlimit(1000000)
(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n):
	x = 0
	y = 0
	for j in range(m):
		x += a[i][j]
	for j in range(m):
		y += b[i][j]
	if x % 2 != y % 2:
		print('No')
		exit()
for j in range(m):
	x = 0
	y = 0
	for i in range(n):
		x += a[i][j]
	for i in range(n):
		y += b[i][j]
	if x % 2 != y % 2:
		print('No')
		exit()
print('Yes')


def rowsum(grid, i):
	return sum(grid[i])

def colsum(grid, i):
	return sum([grid[j][i] for j in range(len(grid))])

def compat(grid1, grid2, r, c):
	for i in range(r):
		if (rowsum(grid1, i) - rowsum(grid2, i)) % 2 != 0:
			return 'No'
	for i in range(c):
		if (colsum(grid1, i) - colsum(grid2, i)) % 2 != 0:
			return 'No'
	return 'Yes'
(r, c) = [int(x) for x in input().split()]
grid1 = []
for _ in range(r):
	grid1.append([int(x) for x in input().split()])
grid2 = []
for _ in range(r):
	grid2.append([int(x) for x in input().split()])
print(compat(grid1, grid2, r, c))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(a, b) = ([list(map(int, input().split())) for _ in range(n)], [list(map(int, input().split())) for _ in range(n)])
for i in range(n):
	if sum((a[i][j] for j in range(m))) % 2 != sum((b[i][j] for j in range(m))) % 2:
		print('No')
		sys.exit(0)
for j in range(m):
	if sum((a[i][j] for i in range(n))) % 2 != sum((b[i][j] for i in range(n))) % 2:
		print('No')
		sys.exit(0)
print('Yes')


(n, m) = map(int, input().split())
first = [[bool(int(i)) for i in input().split()] for j in range(n)]
second = [[bool(int(i)) for i in input().split()] for j in range(n)]
for i in range(n):
	k1 = 0
	k2 = 0
	for j in range(m):
		if first[i][j]:
			k1 += 1
		if second[i][j]:
			k2 += 1
	if k1 % 2 != k2 % 2:
		print('No')
		exit(0)
for j in range(m):
	k1 = 0
	k2 = 0
	for i in range(n):
		if first[i][j]:
			k1 += 1
		if second[i][j]:
			k2 += 1
	if k1 % 2 != k2 % 2:
		print('No')
		exit(0)
print('Yes')


(n, m) = map(int, input().split())
mata = [None] * n
for i in range(n):
	mata[i] = list(map(int, input().split()))
matb = [None] * n
for i in range(n):
	matb[i] = list(map(int, input().split()))
for i in range(n - 1):
	for j in range(m - 1):
		if mata[i][j] == 0:
			mata[i][j] = 1
			mata[i + 1][j] ^= 1
			mata[i][j + 1] ^= 1
			mata[i + 1][j + 1] ^= 1
		if matb[i][j] == 0:
			matb[i][j] = 1
			matb[i + 1][j] ^= 1
			matb[i][j + 1] ^= 1
			matb[i + 1][j + 1] ^= 1
if mata == matb:
	print('Yes')
else:
	print('No')


(a, b) = map(int, input().split())
a1 = [list(map(int, input().split())) for _ in range(a)]
a2 = [list(map(int, input().split())) for _ in range(a)]
s1 = sum((sum(t) for t in a1))
s2 = sum((sum(t) for t in a2))
if (s2 - s1) % 2 != 0:
	print('No')
	exit()
r1 = [sum(t) for t in a1]
r2 = [sum(t) for t in a2]
for i in range(a):
	if (r1[i] - r2[i]) % 2 != 0:
		print('No')
		exit()
c1 = [sum((a1[j][i] for j in range(a))) for i in range(b)]
c2 = [sum((a2[j][i] for j in range(a))) for i in range(b)]
for i in range(b):
	if (c1[i] - c2[i]) % 2 != 0:
		print('No')
		exit()
print('Yes')


def solve():
	(n, m) = [int(x) for x in input().split(' ')]
	A = [[int(x) for x in input().split(' ')] for row in range(n)]
	B = [[int(x) for x in input().split(' ')] for row in range(n)]

	def row_par(M, k):
		return sum(M[k]) % 2

	def col_par(M, k):
		return sum([r[k] for r in M]) % 2
	for r in range(n):
		if row_par(A, r) != row_par(B, r):
			return 'No'
	for c in range(m):
		if col_par(A, c) != col_par(B, c):
			return 'No'
	return 'Yes'
print(solve())