You are given an n×m grid, where each cell contains a positive integer. The integer at row i and column j is denoted as Ai,j. You can start your walk from any cell in the grid and move in four cardinal directions: up, down, left, and right. However, there is a restriction on the movement: you can only move to a neighboring cell if its integer value is strictly smaller than the integer value of the cell you are currently standing on.
For test 1 ~ 4
For test 5 ~ 10
output a single integer, the length of the longest path you can traverse starting from any cell and following the movement constraints.
Remember there should be a ‘\n’ at the end of the last line of output.