You are about to cross an ~N~ by ~N~ 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 ~H~ ~(0 \le H \le 1\,000)~.
Determine whether it is possible to cross the field or not if you start at the top left corner, square ~(1, 1)~, and end in the bottom right corner, square ~(N, N)~.
The first line of input will contain 2 integers: ~N~ and ~H~.
The next ~N~ lines will contain ~N~ integers each, the elevation of that square meter of the field. The elevation will be an integer between ~0~ and ~1\,000~.
On a single line, output
yes if you can cross the field; otherwise, output
|Test Case Batch||Marks||Constraints|
|1 [5 cases]||80||~1 \le N \le 100~|
|2 [2 cases]||20||~1 \le N \le 1\,500~|
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.