#include<bits/stdc++.h>
using namespace std;
long long Power(long long BaSe,long long PoWeR,long long MoD){
//if BaSe zero
BaSe%=MoD;
long long ret=1;
while(PoWeR>0){
if(PoWeR&1) ret=(ret*BaSe)%MoD;
PoWeR>>=1;
BaSe=(BaSe*BaSe)%MoD;
}
if(ret==0) return MoD;
return ret;
}
main(){
int Case;
scanf("%d",&Case);
while(Case--){
long long a,b,m;
scanf("%lld %lld %lld",&a,&b,&m);
printf("%lld\n",Power(a,b,m));
}
return 0;
}
using namespace std;
long long Power(long long BaSe,long long PoWeR,long long MoD){
//if BaSe zero
BaSe%=MoD;
long long ret=1;
while(PoWeR>0){
if(PoWeR&1) ret=(ret*BaSe)%MoD;
PoWeR>>=1;
BaSe=(BaSe*BaSe)%MoD;
}
if(ret==0) return MoD;
return ret;
}
main(){
int Case;
scanf("%d",&Case);
while(Case--){
long long a,b,m;
scanf("%lld %lld %lld",&a,&b,&m);
printf("%lld\n",Power(a,b,m));
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন