Rat in a maze getting tle

sir why am i getting tle in 4th test case.Can you please tell.
my code-https://ide.codingblocks.com/s/98060

because you have to print -1 also in the question , which you left out