#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 8;
const long long mod = 1e9 + 7;
long long fact[maxn], inv[maxn], ifact[maxn];
void calcInv() {
  for (int i = 0; i < 2; i++) {
    fact[i] = 1;
    ifact[i] = 1;
    inv[i] = 1;
  }
  for (int i = 2; i < maxn; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
    long long q = mod / i, r = mod % i;
    inv[i] = (-q * inv[r]) % mod;
    inv[i] = (inv[i] + mod) % mod;
    ifact[i] = (inv[i] * ifact[i - 1]) % mod;
  }
}
const int maxprime = 1e6 + 10, up = sqrt(maxprime);
int prime[maxprime];
inline void sieve() {
  for (int i = 0; i < maxprime; i++) prime[i] = i;
  for (int i = 2; i < maxprime; i += 2) prime[i] = 2;
  for (int i = 3; i <= up; i += 2) {
    if (prime[i] != i) continue;
    int lim = i * i;
    int add = 2 * i;
    for (int j = lim; j < maxprime; j += add) {
      if (prime[j] == j) prime[j] = i;
    }
  }
}
long long fastpow(long long a, long long b) {
  if (b == 0) return 1LL;
  long long temp = fastpow(a, b / 2);
  temp = (temp * temp) % mod;
  if (b % 2 == 1) temp = (temp * a) % mod;
  return temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  calcInv();
  sieve();
  int q;
  cin >> q;
  while (q--) {
    int first, second;
    cin >> first >> second;
    long long ans = 1;
    long long temp = first;
    while (temp > 1) {
      long long f = prime[temp];
      int p = 0;
      while (temp % f == 0) {
        p++;
        temp /= f;
      }
      long long ways = 0;
      for (int i = 1; i <= min(p, second); i++) {
        long long calc = (fact[second] * ifact[i]) % mod;
        calc = (calc * ifact[second - i]) % mod;
        calc = (calc * fact[p - 1]) % mod;
        calc = (calc * ((ifact[i - 1] * ifact[p - i]) % mod)) % mod;
        ways += calc;
      }
      ans = (ans * ways) % mod;
    }
    ans = (ans * fastpow(2, second - 1)) % mod;
    cout << ans << "\n";
  }
  return 0;
}
