At the function of Republic day at NIT Agartala the warden of hostel has to visit the ground and
check the arrangement of the chairs for guests.
In the ground of NIT Agartala all the chairs are arranged in N rows and M columns.

Warden has to check that in each row all the chairs must have same color and adjacent rows have different colors chair.

Input
First line contains two integer N and M.
Next N lines contains M values between 0 to 9 colors of chairs

Output
Print YES if the arrangement is good else print NO.

Example

Input:
5 6
0 0 0 0 0 0
1 1 1 1 1 1
2 2 2 2 2 2
1 1 1 1 1 1
3 3 3 3 3 3
Output:
YES
Input:
5 6
0 0 0 0 1 0
1 1 1 1 1 1
1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3 3 3
Output:
NO
# your code goes here
m,n = map(int,raw_input().split())
a = []
for _ in range(m):
	a.append(map(int,raw_input().split()))

flag = 1
for i in range(m):
	for j in range(n):
		if j > 0:
			if a[i][j-1] != a[i][j]:
				flag = 0
				break
		if i > 0:
			if a[i-1][j] == a[i][j]:
				flag = 0
				break
		
	if flag == 0:
		break

if flag == 0:
	print "NO"
else:
	print "YES"