#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a=m; x%=m; while(n){ if(n&1) v*=x; if(v>=m) flg=1,v%=m; x=x*x%m; n>>=1; } return v+flg*m; } Int mtetra(Int a,Int n,Int m){ if(m==1) return 0; if(n==0) return 1; if(n==1) return a; return mpow(a,mtetra(a,n-1,phi(m)),m); } //END CUT HERE //INSERT ABOVE HERE signed solve(){ Int a,n,m; cin>>a>>n>>m; cout<