#include <bits/stdc++.h>
using namespace std;
int pr[1000005];
void sieve() {
  for (int i = 2; i <= 1000000; i++)
    if (!pr[i])
      for (int j = i; j <= 1000000; j += i)
        if (!pr[j]) pr[j] = i;
}
vector<int> facto(int x) {
  vector<int> ret;
  while (x != 1) {
    ret.push_back(pr[x]);
    x /= pr[x];
  }
  return ret;
}
int dp[20][1000005];
int t;
int x, y;
const int mod = 1e9 + 7;
long long solve(int cur, int idx) {
  if (cur < 0) return 0;
  if (idx == 0) return (cur == 0);
  int &ret = dp[cur][idx];
  if (~ret) return ret;
  ret = solve(cur - 1, idx) + solve(cur, idx - 1);
  if (ret >= mod) ret -= mod;
  return ret;
}
long long C[30][30];
void init() {
  for (int i = 0; i <= 25; i++)
    for (int j = 0; j <= i; j++)
      if ((i == j) || j == 0)
        C[i][j] = 1;
      else
        C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
}
void brute() {
  int n;
  while (cin >> n) {
    long long ans = 0;
    for (int i = 2; i <= n; i += 2) {
      ans += (C[n][i]);
    }
    cout << ans << '\n';
  }
}
long long fast(long long b, long long e) {
  if (!e) return 1;
  return fast(b * b % mod, e >> 1) * ((e & 1) ? b : 1) % mod;
}
int main() {
  init();
  sieve();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  memset(dp, -1, sizeof dp);
  while (t--) {
    cin >> x >> y;
    auto v = facto(x);
    int cnt = 1;
    vector<int> v2;
    for (int i = 1; i < v.size(); i++) {
      if (v[i] == v[i - 1])
        cnt++;
      else
        v2.push_back(cnt), cnt = 1;
    }
    if (x > 1) v2.push_back(cnt);
    long long ans = 1;
    for (int i = 0; i < v2.size(); i++) ans = (ans * solve(v2[i], y)) % mod;
    long long x = fast(2, y - 1);
    x--;
    if (x < 0) x += mod;
    ans += ans * x;
    ans %= mod;
    cout << ans << '\n';
  }
  return 0;
}
