#include using namespace std; const int N = 4e6 + 5; const int mod = 998244353; int q, siz, p[N], vis[N]; vector prime; long long pl[N], inv[N], ipl[N]; void init(int inf){ for(int i = 2; i <= inf; i++){ if(!vis[i]){ prime.push_back(i); vis[i] = i; } for(int v : prime){ if(1ll * i * v > inf) break; vis[i * v] = v; if(i % v == 0) break; } } ipl[0] = ipl[1] = 1, inv[1] = 1, pl[0] = pl[1] = 1; for(int i = 2; i <= inf; i++){ inv[i] = (mod - mod / i) * inv[mod % i] % mod; pl[i] = pl[i - 1] * i % mod; ipl[i] = ipl[i - 1] * inv[i] % mod; } } long long C(int n, int m){ if(m > n) return 0; return pl[n] * ipl[m] % mod * ipl[n - m] % mod; } int main(){ ios::sync_with_stdio(0), cin.tie(0); init(4000000); cin >> q; for(int i = 1, a, b; i <= q; i++){ cin >> a >> b; for(; vis[a]; a /= vis[a]){ siz++; } cout << C(siz - 1, b - 1) << '\n'; } return 0; }