from sys import stdin input=lambda :stdin.readline()[:-1] mod=998244353 M=(10**5)*3+1 fac=[1]*M ninv=[1]*M finv=[1]*M for i in range(2,M): fac[i]=fac[i-1]*i%mod ninv[i]=(-(mod//i)*ninv[mod%i])%mod finv[i]=finv[i-1]*ninv[i]%mod def binom(n,k): if n<0 or k<0: return 0 if k>n: return 0 return (fac[n]*finv[k]%mod)*finv[n-k]%mod N=2*10**5+10 B=450 memo=[] for i in range(B): a=[0]*(B*i+1) res=0 for j in range(B*i+1): res+=binom(B*i,j) res%=mod a[j]=res memo.append(a) inv2=pow(2,mod-2,mod) pow2=[1] for _ in range(M): pow2.append(pow2[-1]*2%mod) T=int(input()) ans=[0]*T for i in range(T): n,m=map(lambda x:int(x)-1,input().split()) n0=(n+B-1)//B*B res=memo[n0//B][m] while n0>n: res=inv2*(res+binom(n0-1,m)) res%=mod n0-=1 ans[i]=res*(pow2[n+1]-1)%mod print(*ans,sep='\n')