#include using namespace std; using i64 = long long; const int N = 1e5 + 10, M = 2e6 + 10, P = 998244353; vector primes; int cnt[N], inv[M], fact[M], invFact[M]; int C(int n, int m) { if(m < 0 || m > n) return 0; return fact[n] * (i64)invFact[m] % P * invFact[n - m] % P; } int main() { ios::sync_with_stdio(false); cin.tie(0); for(int i = 2; i < N; i ++) { if(!cnt[i]) { cnt[i] = 1; primes.push_back(i); } for(int j : primes) { if((i64)i * j >= N) break; cnt[i * j] = cnt[i] + 1; if(i % j == 0) break; } } inv[1] = fact[0] = fact[1] = invFact[0] = invFact[1] = 1; for(int i = 2; i < M; i ++) { inv[i] = (P - P / i) * (i64)inv[P % i] % P; fact[i] = fact[i - 1] * (i64)i % P; invFact[i] = invFact[i - 1] * (i64)inv[i] % P; } int q; cin >> q; int tot = 0; for(int i = 1, x, k; i <= q; i ++) { cin >> x >> k; tot += cnt[x]; cout << C(tot - 1, tot - k) << "\n"; } }