import sys input = sys.stdin.readline mod=998244353 from functools import lru_cache @lru_cache(maxsize=None) def calc(a,b,X,k): if a==0 and b==0: if X==0: return 1 else: return 0 ANS=0 for i in range(10): for j in range(10): if i<=a and j<=b: if i+j+k>=10: ANS+=calc((a-i)//10,(b-j)//10,X-1,1) else: ANS+=calc((a-i)//10,(b-j)//10,X,0) ANS%=mod return ANS T=int(input()) for tests in range(T): N,X=map(int,input().split()) print(calc(N,N,X,0)%mod)