Alice is playing a game on an by grid of integers she got for Christmas, which she calls . In one move, she can rebalance a row or column. A rebalancing is an operation performed on a row or column. The operation will be described on rows. First, Alice picks a row, and then she picks a cell in that row. must have value at least . First, she subtracts one from . Then, she looks for the first zero to the right of , and adds one to that cell. If no such cell exists, she does no increment, but is still decremented. Columns are the same, and proceed top-down.
Alice really likes the grid , because Bob got it for Christmas and she is jealous. Please tell Alice if it is possible to achieve after some amount of rebalancings.
Constraints
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line contains space-separated integers and .
The next lines contain space-separated integers representing grid .
The last lines contain space-separated integers representing grid .
Output Specification
Output YES
if can be achieved after some amount of rebalancings, and NO
otherwise.
Sample Input
2 3
2 2 0
0 0 0
0 0 1
0 1 1
Sample Output
YES
Comments