CODE not working for CHEFCOC

i have tested tons of tc for my code but still WA…
Even the base case of 1X1…
pls help

For the test case
1 1 10000000 1
Your code gives output as 1 but it should be 10000000.
Please note that when matrix is 1*1, output will simply be x. The single cell is not adjacent to any other cell thus the value of y isn’t needed for this case.

Thank you for your help brother…
It means a lot.