#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int max_x = 1e6 + 5;
long long q, x[N], y[N], mark[max_x + 2], fact[max_x + 2];
set<int> second;
void create_primes() {
  for (long long i = 2; i <= max_x; i++) {
    if (!mark[i]) {
      for (long long j = i * i; j <= max_x; j += i) mark[j] = 1;
    }
  }
  for (int i = 2; i <= max_x; i++)
    if (!mark[i]) second.insert(i);
}
void create_fact() {
  fact[0] = 1;
  for (long long i = 1; i <= max_x; i++) fact[i] = (fact[i - 1] * i) % MOD;
}
void read_input() {
  cin >> q;
  for (int i = 0; i < q; i++) cin >> x[i] >> y[i];
}
int Count(long long a, long long b) {
  int out = 0;
  while (a % b == 0) out++, a /= b;
  return out;
}
long long binpow(long long a, long long b) {
  if (b == 0) return 1LL;
  long long c = binpow(a, b / 2);
  return (c * c) % MOD * (b & 1 ? a : 1LL) % MOD;
}
long long inv(long long a) { return binpow(a, MOD - 2) % MOD; }
long long C(long long a, long long b) {
  if (a < b) return 0LL;
  if (b == 0) return 1LL;
  return fact[a] * inv(fact[b] * fact[a - b] % MOD) % MOD;
}
void solve() {
  for (int i = 0; i < q; i++) {
    long long ans = 1;
    bool is_prime = true;
    if (x[i] == 1) {
      cout << binpow(2LL, y[i] - 1) << '\n';
      continue;
    }
    for (int j = 1; j * j <= x[i]; j++) {
      if (x[i] % j) continue;
      is_prime = false;
      long long max_pow;
      long long cnt = 0;
      if (second.find(j) != second.end()) {
        max_pow = Count(x[i], j);
        for (long long k = 1; k <= max_pow; k++) {
          cnt = (cnt + C(y[i], k) * C(max_pow - 1, k - 1)) % MOD;
        }
        ans = (ans * cnt) % MOD;
      }
      cnt = 0;
      if (j * j < x[i] && second.find(x[i] / j) != second.end()) {
        long long cnt = 0;
        max_pow = Count(x[i], x[i] / j);
        for (long long k = 1; k <= max_pow; k++) {
          cnt = (cnt + C(y[i], k) * C(max_pow - 1, k - 1)) % MOD;
        }
        ans = (ans * cnt) % MOD;
      }
    }
    if (is_prime) {
      long long max_pow = 1;
      long long cnt = 0;
      for (long long k = 1; k <= max_pow; k++) {
        cnt = (cnt + C(y[i], k) * C(max_pow - 1, k - 1)) % MOD;
      }
      ans = (ans * cnt) % MOD;
    }
    cout << (ans * binpow(2LL, y[i] - 1)) % MOD << '\n';
  }
}
void write_output() {}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  create_primes();
  create_fact();
  int t = 1;
  while (t--) {
    read_input();
    solve();
    write_output();
  }
}
