Modular exponentiation

not able to figure out the test case which is creating problem, when my code is running for 9/10 test cases


refer this