n=int(input()) M=998244353 fa=[1,1] fb=[1,1] for i in range(2,3*10**6+1): fa+=[fa[-1]*i%M] fb+=[fb[-1]*(M//i)*fb[M%i]*fa[M%i-1]*(-1)%M] fc=lambda n,k:fa[n]*fb[k]*fb[n-k]%M if n>=k else 0 f=lambda b,c:fc(c-b+b-1,b-1) c=0 for _ in range(n): a,b=map(int,input().split()) i=2 while i*i<=a: if a%i==0: while a%i==0: a//=i c+=1 i+=1 c+=a>1 print(f(b,c))