#ifndef call_from_test #include using namespace std; #define call_from_test #ifndef call_from_test #include using namespace std; #endif //BEGIN CUT HERE template T totient(T n){ T res=n; for(T i=2;i*i<=n;i++){ if(n%i==0){ res=res/i*(i-1); for(;n%i==0;n/=i); } } if(n!=1) res=res/n*(n-1); return res; } //END CUT HERE #ifndef call_from_test signed main(){ return 0; } #endif #undef call_from_test #endif //BEGIN CUT HERE template T mpow(T a,T n,T m,T &f){ using ull = unsigned long long; if(a==1||n==0) return 1; ull v=1,x=a,z=m; f|=x>=z; x%=m; while(1){ if(n&1) v*=x; if(v>=z) f=1,v%=m; n>>=1; if(!n) break; x=x*x; if(x>=z) f=1,x%=m; } return v; } template T tetration(T a,T n,T m,T &f){ if(a==0) return ~n&1; if(m==1) return f=1; if(a==1||n==0) return 1; if(n==1){ f|=a>=m; return a%m+f*m; } T z=tetration(a,n-1,totient(m),f); T r=mpow(a,z,m,f); return r+f*m; } template T tetration(T a,T n,T m){ T f=0; return tetration(a,n,m,f)%m; } //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed YUKI_181(){ int a,n,m; cin>>a>>n>>m; cout<>a>>m>>k; ll ans=0; k--; for(ll i=0,p=-1;i>T; while(T--){ ll a,n,f=0; cin>>a>>n; stringstream ss; ss<>T; while(T--){ ll a,n,m; cin>>a>>n>>m; cout<