Please tell me the error in m y code due to which only 1 test case pass

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll int power(ll int &ans,ll int i,ll int p)
{
if(i==0)
{
return 1;
}
else
{
int subp=power(ans,i/2,p);
if(i&1)
{
return (anssubpsubp)%p;
}
else
{
return (anssubpsubp)%p;
}
}
}
int main() {
int t;
cin>>t;
while(t–)
{
ll int a,n,p;
cin>>a>>n>>p;
ll int ans=a%p;
for(int i=2;i<=n;i++)
{
ans=power(ans,i,p);
}
cout<<ans<<endl;

}
return 0;

}

@Ankit_kumar_3003
your power function was wrong.

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.