#include <bits/stdc++.h>
using namespace std;
long long t, x, y, ans, cnt, mod = 1e9 + 7, a[2000001], b[2000001], c[2000001];
inline long long read() {
  long long sum = 0, x = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
inline long long work(long long x, long long y) {
  if (x < 0 || y < 0 || x < y) return 0;
  return a[x] * c[y] % mod * c[x - y] % mod;
}
inline long long dfs(long long x, long long y) {
  if (y == 0) return 1;
  return dfs(x * x % mod, y / 2) * (y % 2 ? x : 1) % mod;
}
signed main() {
  b[0] = b[1] = a[0] = c[0] = 1;
  for (register long long i = 1; i < 2000001; ++i) a[i] = a[i - 1] * i % mod;
  for (register long long i = 2; i < 2000001; ++i)
    b[i] = b[mod % i] * (mod - mod / i) % mod;
  for (register long long i = 1; i < 2000001; ++i) c[i] = c[i - 1] * b[i] % mod;
  t = read();
  while (t--) {
    y = read();
    x = read();
    ans = dfs(2, x - 1);
    for (register long long i = 2; i * i <= y; ++i)
      if (y % i == 0) {
        cnt = 0;
        while (y % i == 0) {
          y /= i;
          ++cnt;
        }
        ans = ans * work(cnt + x - 1, x - 1) % mod;
      }
    if (y != 1) ans = ans * x % mod;
    write(ans);
    putchar('\n');
  }
  return 0;
}
