g(n)=∑f(d)^3 (d|n,f(n)表示n的约数个数)
易证g(n)为积性函数,即(n,m)=1 g(nm)=g(n)*g(m)
则 若n=p1^a1 * p2^a2 ……pj^aj
g(n)=g(p1^a1)*……g(pj^aj)
易证g(n)为积性函数,即(n,m)=1 g(nm)=g(n)*g(m)
则 若n=p1^a1 * p2^a2 ……pj^aj
g(n)=g(p1^a1)*……g(pj^aj)
由定义知g(p1^a1)=1^3+……(a1+1)^3=(a1+1)^2*(a1+2)^2 /4
const LL mod = 10007LL ;
const int maxn = 10008 ;
bool is[maxn] ;
int ps ;
int prime[maxn] ;
void make(){
memset(is , 0 , sizeof(is)) ;
ps = 0 ;
for(int i = 2 ; i < maxn ; i++){
if(! is[i]) prime[ps++] = i ;
for(int j = 0 ; j < ps && i * prime[j] < maxn ; j++){
is[i * prime[j]] = 1 ;
if(i % prime[j] == 0) break ;
}
}
}
vector< pair<int , int> > plis ;
void get_pfactor(LL n){
plis.clear() ;
for(int i = 0 ; i < ps && prime[i] * prime[i] <= n ; i++){
if(n % prime[i] == 0){
int c = 0 ;
while(n % prime[i] == 0){
c++ ;
n /= prime[i] ;
}
plis.push_back(make_pair(prime[i] , c)) ;
}
}
if(n != 1) plis.push_back(make_pair(n , 1)) ;
}
LL Pow(LL x , LL y){
LL s = 1 ;
for(; y ; y >>= 1){
if(y & 1){
s *= x ;
s %= mod ;
}
x *= x ;
x %= mod ;
}
return s ;
}
LL sum3(LL n){
LL t = 1 ;
t *= Pow(n , 2) ;
t %= mod ;
t *= Pow(n+1 , 2) ;
t %= mod ;
t *= Pow(4 , mod-2) ;
t %= mod ;
return t ;
}
int main(){
make() ;
LL a , b , ans , n ; int T = 1 ;
while(cin>>a>>b){
get_pfactor(a) ;
ans = 1 ;
for(int i = 0 ; i < plis.size() ; i++){
LL p = (LL)plis[i].first ;
n = b * (LL)plis[i].second ;
ans *= sum3(n+1) ;
ans %= mod ;
}
printf("Case %d: %I64d\n" , T++ , ans ) ;
}
return 0 ;
}