#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
#define tt ull tt; cin>>tt; while(tt--)
ull calExpo(ull x, ull y, ull mod){
ull res=1;
while(y>0){
if(y&1){
res=(res*x)%mod;
}
y=y>>1;
x=(x*x)%mod;
}
return res;
}
void solve(void){
tt{
ull x,y,z;
cin>>x>>y>>z;
ull mod=1000000007;
ull t= calExpo(y,z,mod-1); // doubt is in this line
cout<<calExpo(x,t,mod)<<endl;
}
}
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
solve();
return 0;
}
i wrote code for CSES problem https://cses.fi/problemset/task/1712/ (problem description in short: give n test cases for each n there are 3 integer values a,b,c we have to calculate a^b^c (a to the power b and b to the power c) given mod=10^9+7 ) i was getting error when i passed only (mod) as third argument while calling function (calExpo) for first time (in line ull t= calExpo(y,z,mod-1); ) then i passed mod-1 and it passed all test cases . please tell me what is the reason behind that?