


1. If the move isn’t possible you remain in that cell only.
The first line of the input contains two space-separated integers 'N' and ‘M’, denoting the number of rows and columns of the matrix respectively.
Next, there will be N lines each containing M space-separated integers denoting the description of the matrix.
The next line contains two space-separated integers ‘Sx’, ‘Sy’ denoting the indexes of the source cell
The next line contains two space-separated integers ‘Dx’, ‘Dy’ denoting the indexes of the destination cell
If a path exists then print the length of the longest possible path from source to destination.
Otherwise, print -1.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= N, M <= 12 , such that N+M <=12
0 <= Mat[i][j] <= 1 ,
0 <= Sx, Dx <= N-1
0 <= Sy, Dy <= M-1
Where Mat[i][j] is the value at position i,j in the matrix.
The algorithm will be like this: