#include<bits/stdc++.h>
using namespace std;
int qmi(int a, int k, int p)
{
int res = 1;
while(k)
{
if(k & 1) res = (long long)res * a % p;
k >>= 1;
a = (long long)a * a % p;
}
return res;
}
int main()
{
int n;
cin >> n;
while(n --)
{
int a, k, p;
scanf("%d%d%d", &a, &k, &p);
cout << qmi(a, k, p) << endl;
}
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-35532.html