#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast") #include #include using namespace std; #if __has_include() #include using namespace atcoder; #endif using ll = long long; using ld = long double; using ull = unsigned long long; #define endl "\n" typedef pair Pii; #define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i)) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(x) begin(x), end(x) #define all(s) (s).begin(),(s).end() //#define rep2(i, m, n) for (int i = (m); i < (n); ++i) //#define rep(i, n) rep2(i, 0, n) #define PB push_back #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define rever(vec) reverse(vec.begin(), vec.end()) #define sor(vec) sort(vec.begin(), vec.end()) //#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define fi first #define se second #define pb push_back #define P pair #define NP next_permutation //const ll mod = 1000000009; ll mod = 998244353; //const ll mod = 1000000007; const ll inf = 4100000000000000000ll; const ld eps = ld(0.00000000001); //static const long double pi = 3.141592653589793; templatevoid vcin(vector &n){for(int i=0;i>n[i];} templatevoid vcin(vector &n,vector &m){for(int i=0;i>n[i]>>m[i];} templatevoid vcout(vector &n){for(int i=0;ivoid vcin(vector> &n){for(int i=0;i>n[i][j];}}} templatevoid vcout(vector> &n){for(int i=0;iauto min(const T& a){ return *min_element(all(a)); } templateauto max(const T& a){ return *max_element(all(a)); } templatevoid print(pair a){cout<bool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b void ifmin(T t,T u){if(t>u){cout<<-1< void ifmax(T t,T u){if(t>u){cout<<-1<auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector(arg,x);else return vector(arg,make_vector(x,args...));} ll fastgcd(ll u,ll v){ll shl=0;while(u&&v&&u!=v){bool eu=!(u&1);bool ev=!(v&1);if(eu&&ev){++shl;u>>=1;v>>=1;}else if(eu&&!ev){u>>=1;}else if(!eu&&ev){v>>=1;}else if(u>=v){u=(u-v)>>1;}else{ll tmp=u;u=(v-u)>>1;v=tmp;}}return !u?v<>= 1; } return ret; } vector divisor(ll x){ vector ans; for(ll i = 1; i * i <= x; i++){ if(x % i == 0) {ans.push_back(i); if(i*i!=x){ ans.push_back(x / ans[i]);}}}sor(ans); return ans; } ll pop(ll x){return __builtin_popcountll(x);} ll poplong(ll x){ll y=-1;while(x){x/=2;y++;}return y;} template struct Sum{ vector data; Sum(const vector& v):data(v.size()+1){ for(ll i=0;i struct Sum2{ vector> data; Sum2(const vector> &v):data(v.size()+1,vector(v[0].size()+1)){ for(int i=0;i1){ ll t=(ok+ng)/2; if(t*t<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i<=a&&(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==3){ ll ok=1,ng=2000000; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(t*t*t<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i<=a&&(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==4){ ll ok=1,ng=38000; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(t*t*t*t<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i*i<=a&&(i+1)*(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==5){ ll ok=1,ng=4580; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(modPow(t,5,inf)<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i*i*i<=a&&(i+1)*(i+1)*(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==6){ ll ok=1,ng=1130; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(modPow(t,6,inf)<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i*i*i*i<=a&&(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==7){ ll ok=1,ng=420; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(modPow(t,7,inf)<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i*i*i*i*i<=a&&(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==8){ ll ok=1,ng=200; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(modPow(t,8,inf)<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i*i*i*i*i*i<=a&&(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==9){ ll ok=1,ng=110; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(modPow(t,9,inf)<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i*i*i*i*i*i*i<=a&&(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else if(b==10){ ll ok=1,ng=70; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; if(modPow(t,10,inf)<=a){ ok=t; } else{ ng=t; } } for(ll i=ok-3;i<=ok+3;i++){ if(i<=0) continue; if(i*i*i*i*i*i*i*i*i*i<=a&&(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)*(i+1)>a){ return max(i-1,0ll); } } } else{ if(b>=40){ ll ans=0; if(check(a,2,b)) ans++; return ans; } if(b>=32){ ll ans=0; if(check(a,2,b)) ans++; if(check(a,3,b)) ans++; return ans; } for(ll i=2;i<=a;i++){ ll k=a; for(int j=0;j>k; k=1000000000; ll ok=0,ng=2000000000000000000ll; while(abs(ok-ng)>1){ ll t=(ok+ng)/2; ll now=0; for(ll i=2;i<=64;i++){ ll p=subsolve(t,i); ll z=1; // cout<=k){ ng=t; } else{ ok=t; } } cout<>t; while(t--){ solve(); } }