Snake and Ladder board problem

I am getting TLE in this problem…can you guide me where i am doing mistake?
please explain…

@Nisha21 hey you have not input the no of test cases and secondly make arr[1000] = {0} instead of arr[n] = {0}.