You are about to cross an by meter field. However, you are not sure if it's actually possible to do so. Each square meter of the field has an elevation value — you may only cross into an adjacent square meter if the distance between the centres of the squares is equal to one and if the elevation difference between the squares is less than or equal to .
Determine whether it is possible to cross the field or not if you start at the top left corner, square , and end in the bottom right corner, square .
The first line of input will contain 2 integers: and .
The next lines will contain integers each, the elevation of that square meter of the field. The elevation will be an integer between and .
On a single line, output
yes if you can cross the field; otherwise, output
|Test Case Batch||Marks||Constraints|
|1 [5 cases]||80|
|2 [2 cases]||20|
4 3 3 6 4 9 7 1 2 3 7 7 2 2 7 7 1 5
Explanation for Sample Output
From the top left square, you can go right, right, down, down, right, down to reach the bottom right square.