two testcases are not passing .
below is my code -
#include<bits/stdc++.h>
using namespace std;
long long power(int a,int n)
{
if(n==0)
{
return 1;
}
int subprob = power(a,n/2);
if(n&1)
{
return a*subprob*subprob;
}
return subprob*subprob;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int a,n,p;
cin>>a>>n>>p;
long long ans = a;
for(int i=2;i<=n;i++)
{
ans = power(ans%p,i);
}
cout<<ans%p<<endl;
}
return 0 ;
}