#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair P; const ll MOD=100000009; vector

f[37]; int main() { for(int i=2; i<=36; i++){ int i1=i; for(int j=2; j<=31; j++){ if(i1%j==0){ int e=0; while(i1%j==0){ i1/=j; e++; } f[i].push_back(P(j, e)); } } } int q; cin>>q; for(int t=0; t>s; int n, k, b; cin>>n>>k>>b; int ans=1e9; for(int j=0; j v; ll x=s; for(int i=0; i<=n; i++){ int e1=0; ll x1=x; while(x1%p==0){ x1/=p; e1++; } v.push_back(e1); x=1+(x*x+x*12345)%MOD; } sort(v.begin(), v.end()); int ct=0; for(int i=0; i