#include<bits/stdc++.h>
using namespace std;
#define ll long long
#ifndef ONLINE_JUDGE
#define dbg(x) cout << #x << ":- " << x << "\n"
#else
#define dbg(x)
#endif
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(),x.rend()
#define MOD 1000000007
//-----------------------------------------------------------------------------//
void print(vector<ll>arr){for(int i=0;i<arr.size();i++){cout<<arr[i]<<" ";}
cout<<endl;}
void print(map<ll,ll>mpp){for(auto x:mpp){cout<<x.first<<"-->"<<x.second<<"\n";}
cout<<endl;}
void print(set<ll>s){for(auto x:s){cout<<x<<" ";}cout<<endl;}
/* OBSERVATIONS
//------------------------------------------------------------------------------//
let say i have x
then if p is the smallest pf
and q is the largest pf
then,
if k is even
we do
x* p^(k/2)
q^(k/2)
//------------------------------------------------------------------------------//
*/
vector<int>primes;
void sieve_of_eratosthenes(int n) {
vector<bool> is_prime(n + 1, true);
is_prime[0] = is_prime[1] = false; // 0 and 1 are not prime numbers
for (int i = 2; i * i <= n; ++i) {
if (is_prime[i]) {
// Marking all multiples of i as not prime
for (int j = i * i; j <= n; j += i) {
is_prime[j] = false;
}
}
}
for (int i = 2; i <= n; ++i) {
if (is_prime[i]) {
primes.push_back(i);
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
sieve_of_eratosthenes(1e5);
int t;
cin>>t;
while(t--){
ll n,k;
cin>>n>>k;
ll tempN=n;
ll p=-1;
ll q=-1;
for(int i=0;i<primes.size();i++){
if(n%primes[i]==0){
if(p==-1)p=primes[i];
q=primes[i];
while(n>0&&(n%primes[i]==0))n/=primes[i];
}
}
if(n>1)q=n;
// dbg(p);
// dbg(q);
ll pp=(k+1)/2;
long double temp=pp*(log10l(p)-log10l(q));
long double tempp=powl(10.0,temp);
// dbg(tempp);
long double ans=-1;
if(k&1){
ans=tempp*q*tempN;
}
else{
ans=tempp*tempN;
}
cout<<roundl(ans)<<"\n";
}
return 0;
}