def main(): import sys input = sys.stdin.read data = input().split() H = int(data[0]) W = int(data[1]) grid = data[2:] # Check if the entire grid is already all 1s all_ones = True for row in grid: if '0' in row: all_ones = False break if all_ones: if H * W == 1: print("YES") else: print("NO") return # Calculate the required flips F_ij = 1 - A_ij required = [] for row in grid: req = [] for c in row: req.append(1 - int(c)) required.append(req) # Check for possible configurations # We need to determine if the required flips can be achieved # through a series of splits and mandatory flips. # For this problem, the solution is to check if the sum of all required flips is even. total = 0 for row in required: total += sum(row) if total % 2 == 0: print("YES") else: print("NO") if __name__ == "__main__": main()