Problem
Eric found an LED board in his grandfather's old garage. However, he was surprised that when activated, the diodes were not synchronized with each other. That is, some of them burned, and some did not.
The board itself turned out to be unusual. It is a rectangular grid with n rows and m columns, where each cell contains one diode. Near each row there is a lever that switches all the diodes in this row (burning diodes go out and vice versa). Each column has the same levers (which I use the diodes in the corresponding column).
Eric wondered if it was possible to switch the diodes to the same state by switching levers.
Input:
The first line contains two natural numbers n and m (1 <= n, m <= 7) - the number of rows and columns on the board, respectively.
Then there are n lines with m numbers each - the states of the diodes, where 0 means that the diode is off, and 1 that it is on.
Output:
Print "YES" if it is possible to bring the diodes into one state and "NO" if it is impossible.
Examples:
Input |
Output |
2 2
0 1
10 |
YES |
2 2
0 1
0 0
| NO |
Explanation:
In the first example, you can switch all diodes in the first row, then switch all diodes in the first column. Then all diodes will be off.