题解 | #【模板】快速幂Ⅰ ‖ 整数#
【模板】快速幂Ⅰ ‖ 整数
https://www.nowcoder.com/practice/3d624107a6904da1bd0e8c9c85e17167
t = int(input())
def qpow(x,y,mod):
res = 1
while y:
if y & 1:
res *= x
res %= mod
x *= x
x %= mod
y >>= 1
return res % mod
for _ in range(t):
x,y,p = map(int,input().split())
print(qpow(x,y,p))

