#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long fac[2000000 + 5];
int pri[2000000 + 5], no_pri[2000000 + 5], dy[2000000 + 5], tot[2000000 + 5],
    now[2000000 + 5], inv[2000000 + 5];
int q, cnt;
long long qvod(int a, int b) {
  long long res = 1, base = a % mod;
  while (b) {
    if (b & 1) res = res * base % mod;
    base = base * base % mod;
    b >>= 1;
  }
  return res;
}
void get_pri() {
  for (int i = 2; i < 2000000 + 5; i++) {
    if (!no_pri[i]) {
      pri[++cnt] = i;
      dy[i] = cnt;
    }
    for (int j = 1; j <= cnt && pri[j] * i < 2000000 + 5; j++) {
      no_pri[pri[j] * i] = 1;
      dy[pri[j] * i] = j;
      if (i % pri[j] == 0) break;
    }
  }
}
void di(int x, int tag) {
  while (x != 1) {
    if (now[dy[x]] != tag) {
      now[dy[x]] = tag;
      tot[dy[x]] = 1;
    } else {
      tot[dy[x]]++;
    }
    x /= pri[dy[x]];
  }
}
long long C(int n, int m) { return fac[n] * inv[m] % mod * inv[n - m] % mod; }
int main() {
  get_pri();
  scanf("%d", &q);
  fac[0] = fac[1] = 1;
  for (int i = 2; i < 2000000 + 5; i++) fac[i] = fac[i - 1] * i % mod;
  inv[0] = 1;
  for (int i = 1; i < 2000000 + 5; i++) inv[i] = qvod(fac[i], mod - 2);
  int x, y, sum;
  long long ans;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    di(x, i);
    ans = 1;
    while (x != 1) {
      if (now[dy[x]] == i) {
        ans = ans * C(tot[dy[x]] + y - 1, y - 1) % mod;
        now[dy[x]] = 0;
      }
      x /= pri[dy[x]];
    }
    ans = ans * qvod(2, y - 1) % mod;
    printf("%I64d\n", ans);
  }
  return 0;
}
