TLE in Math day problem

for _ in range(int(input())):

x,y,mod=map(int,input().split())

ans=x

def exponentiation(x,y,mod):

	result=1



	while(y):

	   

		if y%2==1:

			result=result*x%mod

		if y==1:

		    break

		x=x*x%mod

		y=y>>1

	return result

for i in range(2,y+1):

	ans=exponentiation(ans,i,mod)%mod

print(ans%mod)

i am getting TLE in the last two test cases. Is it because I am using Python or i have written something wrong in my code?. I think my code is correct.

@govilayush
It was a Python problem only. I have updated the time limit for Python3. Try your code again.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.