#include #if __has_include() #endif using namespace std; #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define FO(n) for(ll IJK=n;IJK-->0;) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);i(1,__VA_ARGS__);i>=i##stop;i+=i##step) #define defpp templatevoid pp(const auto&...a){[[maybe_unused]]const char*c="";((o<(a...);} #define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{ #define multiple_testcases LL(T);FO(T)main2();}void main2(){ namespace my{ void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<constexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} templateconstexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};} void lin(auto&...a){(cin>>...>>a);} constexpr auto abs(auto x){return x<0?-x:x;} constexpr ll size2(auto x){x|=1;ll r=0;while(x>0)x>>=1,++r;return r;} constexpr ll log2_floor(auto x){return size2(x)-1;} auto floor(auto x,auto y){if(y<0)x=-x,y=-y;return x>=0?x/y:(x+1)/y-1;} auto max(auto...a){return max(initializer_list>{a...});} templatecommon_type_tgcd(T a,U b){return b?gcd(b,a%b):abs(a);} auto bot(auto...a){return gcd(a...)==1;} constexpr ui64 kth_root_floor(ui64 a,ll k){ if (k==1)return a; auto within=[&](ui32 x){ui64 t=1;FO(k)if(__builtin_mul_overflow(t,x,&t))return false;return t<=a;}; ui64 r=0; of(i,sizeof(ui32)*CHAR_BIT)if(within(r|(1u<=2のとき fo(bb,1,M+1)fo(dd,1,M+1){ if(!bot(bb,dd))continue; ans+=(kth_root_floor(N,max(bb,dd))-1)*floor(N,max(bb,dd)); } pp(ans); }}