#include<bits/stdc++.h> using namespace std; /**** * 超级积性函数线性筛 * ****/ typedef unsigned int uint; typedef unsigned long long ull; const uint maxn=1e7+100; uint no_pri[maxn]={0,1,0},pri[maxn],low[maxn]; uint PHI[maxn],phu[maxn],f2[maxn],f3[maxn]; void f_ini(){ for(uint i=2;i<maxn;i++){ if(!no_pri[i]) low[i]=pri[++pri[0]]=i; for(uint j=1;1ll*pri[j]*i<maxn;j++){ no_pri[pri[j]*i]=1; if(i%pri[j]==0) { low[pri[j]*i]=low[i]*pri[j]; break; } else low[pri[j]*i]=pri[j]; } } PHI[1]=phu[1]=f2[1]=f3[1]=1;// 改这里 for(uint i=1;i<=pri[0];i++){ for(ull mul=pri[i],ct=1;mul<maxn;mul*=pri[i],ct++){ uint pre=mul/pri[i]; PHI[mul]=mul/pri[i]*(pri[i]-1);// 改这里 phu[mul]=PHI[mul]-PHI[pre]; f2[mul]=ct%2==1?(f2[pre]*pri[i]):f2[pre]; f3[mul]=ct%3==1?(f3[pre]*pri[i]):f3[pre]; } } for(uint i=2;i<maxn;i++){ for(uint j=1;1ll*pri[j]*i<maxn;j++){ uint x=low[i*pri[j]], y=i*pri[j]/x; phu[x*y]=phu[x]*phu[y]; f2[x*y]=f2[x]*f2[y]; f3[x*y]=f3[x]*f3[y]; if(i%pri[j]==0) break; } } } int main(){ f_ini(); uint t; cin>>t; while(t--) { uint a,b,c; cin>>a>>b>>c; uint ans=0; uint n=min(min(1.0*a,1.0*b*b),1.0*c*c*c)+0.5; for(uint i=1;i<=n;i++){ ans+=phu[i]*(a/i)*(b/f2[i])*(c/f3[i]); } ans&=0x3fffffff; cout<<ans<<endl; } return 0; } /* 4 96 93 95 970 906 893 92460 95043 54245 9760979 8053227 7156842 */