#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 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; } //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; } //END CUT HERE //INSERT ABOVE HERE signed YUKI_181(){ int a,n,m,f=0; cin>>a>>n>>m; cout<>T; while(T--){ int a,n,f=0; cin>>a>>n; stringstream ss; ss<>T; while(T--){ int a,n,m,f=0; cin>>a>>n>>m; cout<>a>>m>>k; int ans=0; k--; for(int i=0,p=-1;i