Algorithm: Number theory , Inverse Modulo
#include < bits/stdc++.h>
using namespace std ;
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
#define ll long long
#define vi vector<int >
#define pii pair<int , int >
#define pll pair<ll, ll>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int ,int >>
#define vpll vector<pair<ll,ll>>
int Set (int N, int pos) {return N = N | (1 <<pos);}
int Reset (int N, int pos) {return N = N & ~(1 <<pos);}
bool Cheek (int N, int pos) {return (bool )(N & (1 <<pos));}
#define least_one_pos (x ) __builtin_ffs(x)
#define leading_zeros (x ) __builtin_clz(x)
#define tailing_zeros (x ) __builtin_ctz(x)
#define num_of_one (x ) __builtin_popcount(x)
// /............x...........///
#define all (a ) a.begin(), a.end()
#define allr (a ) a.rbegin(), a.rend()
#define mp (a, b ) make_pair(a, b)
#define pb push_back
#define UNIQUE (X ) (X).erase(unique(all(X)), (X).end())
#define ft cout << " for test" <<endl;
#define print (v ) for (auto it : v)cout << it<<" " ;cout << endl;
#define PI acos (-1.0 )
#define FIO ios_base::sync_with_stdio (0 );cin.tie(0 );cout.tie(0 );
#define t_c int test, cs = 1 ;cin>>test;while (test--)
// /................function.....................///
#define mod 1000000007
// ........constant........///
const ll N = 1e6 +5 ;
void file (){
freopen (" input.txt" ," r" ,stdin);
freopen (" output.txt" ," w" ,stdout);
}
ll prime_size=(1 <<16 );
vll primes;
vector<bool > mark (prime_size);
void sieve (){
ll i,j;
mark[0 ]=mark[1 ]=1 ;
for (i=4 ; i<prime_size; i+=2 )mark[i]=1 ;
for (i=3 ; i*i<=prime_size; i+=2 ){
if (!mark[i]){
for (j=i*i; j<=prime_size; j+=i*2 )mark[j]=1 ;
}
}
primes.pb (2 );
for (i=3 ; i<=prime_size; i+=2 )if (!mark[i])primes.pb (i);
}
long long binpow (long long a, long long b, long long m) {
a %= m;
long long res = 1 ;
while (b > 0 ) {
if (b & 1 )
res = res * a % m;
a = a * a % m;
b >>= 1 ;
}
return res;
}
int main (){
FIO;
// file();
sieve ();
t_c{
ll n,m,i,j;
cin>>n>>m;
cout<<" Case " <<cs++<<" : " ;
map<ll,ll>pcnt;
for (auto x:primes){
if (x*x>n)break ;
if (n%x==0 ){
int c=0 ;
while (n%x==0 ){
n/=x;
c++;
}
pcnt[x]=c;
}
}
if (n>1 )pcnt[n]=1 ;
ll ans=1ll ;
for (auto x:pcnt){
ll p = x.first ;
ll e = x.second *m;
ll up = (binpow (p,e+1 ,mod)-1 +mod)%mod;
ll dwn = binpow (p-1 ,mod-2 ,mod);
ans = ans*(up*dwn%mod)%mod;
}
cout<<(ans+mod)%mod<<endl;
}
}