#include<iostream>
#include<vector>
#include <cmath>
using namespace std;
vector<long long>p;
long long range = 1000;
void findPrime()
{
for (size_t i = 2; i < range; i++)
{
bool isP = 1;
for (size_t j = 2; j * j <= i; j++)
{
if (i % j == 0)
{
isP = 0;
break;
}
}
if (isP)
{
p.push_back(i);
}
}
}
long long q, n, k;
struct myNum
{
long long pri, ti;
};
int main() {
findPrime();
cin >> q;
for (size_t i = 0; i < q; i++)
{
cin >> n >> k;
vector<myNum>vecNum;
long long aws = 1, temp = n;
for (auto& it : p)
{
if (it * it > n) break;
long long t = 0;
while (temp % it == 0)
{
t++;
temp /= it;
}
if (t != 0)
{
vecNum.push_back({ it,t });
}
}
for (auto& it : vecNum)
{
if (it.ti >= k)
{
aws *= pow(it.pri, it.ti);
}
}
if (aws == 0) aws = 1;
cout << aws << endl;
}
return 0;
system("pause");
}