Alex and Andrei are playing a game on an matrix filled with non-negative integers. The rows of the matrix are numbered from to (from top to bottom), and the columns are numbered from to (from left to right).
Alex is allowed to perform the following operation any number of times:
- Choose a horizontal or vertical subrectangle.
- Select an integer .
- Add to all numbers in the chosen subrectangle, ensuring that no number becomes negative.
Andrei believes that Alex cannot make all the numbers in the matrix zero within at most operations.
Alex is determined to prove him wrong -- but since he hasn't learned addition at school yet, he needs your help. Can you determine whether Alex can reduce the entire matrix to zero within the given limit?
Input data
The first line of the input contains two integers: and .
Each of the next lines contains non-negative integers, representing the elements of the matrix.
Output data
First, print YES
if it is possible to make all equal to zero within at most operations. Otherwise, print NO
.
If the answer is YES
, proceed with the following output:
- Print an integer , the number of operations perfomed.
- Print lines, each describing an operation in the format: where are the coordinates of the top-left corner of the chosen subrectangle, are the coordinates of the bottom-right corner of the subrectangle (that is, and ), and is the integer added to all elements within the subrectangle.
If there are multiple valid solutions, you can print any of them.
Constraints and clarifications
- .
- .
- for each and .
- .
# | Points | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 14 | , . |
3 | 25 | or . |
4 | 7 | All numbers are equal. |
5 | 54 | No additional constraints. |
Example 1
stdin
3 3
1 5 1
2 6 2
8 12 8
stdout
YES
6
1 1 1 3 8
2 1 2 3 7
3 1 3 3 1
1 1 3 1 -9
1 2 3 2 -13
1 3 3 3 -9
Explanation
In the first sample case, there are multiple valid solutions, with the sample output being one of them.
Example 2
stdin
3 3
1 5 0
2 6 2
8 12 8
stdout
NO
Explanation
In the second sample case it can be proven that no sequence of at most operations will lead to a matrix containing only zeros.