H, W = map(int, input().split())
grid = []
for _ in range(H):
    line = input().strip()
    grid.append([int(c) for c in line])

# Calculate the desired flip counts (f_ij = 1 - A_ij)
total = 0
column_sums = [0] * W
for i in range(H):
    for j in range(W):
        f = 1 - grid[i][j]
        total += f
        column_sums[j] += f

total_mod = total % 2
possible = True

# Check total condition
if total_mod != 0:
    possible = False
else:
    # Check each column's condition
    for j in range(W):
        sum_col = column_sums[j] % 2
        expected = (H - 1) % 2
        if sum_col != expected:
            possible = False
            break

print("YES" if possible else "NO")