import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 d = {} def f(na, nb, x, c): if (na, nb, x, c) in d: return d[na, nb, x, c] ans = 0 if na == nb == 0: if x == 0: ans = 1 else: ans = 0 else: for a in range(min(na + 1, 10)): for b in range(min(nb + 1, 10)): if a + b + c < 10: ans += f((na - a) // 10, (nb - b) // 10, x, 0) elif x > 0: ans += f((na - a) // 10, (nb - b) // 10, x - 1, 1) d[na,nb,x,c] = ans % mod return d[na,nb,x,c] def dsum(x): ans = 0 while x > 0: ans += x % 10 x //= 10 return ans for _ in range(ii()): n, x = mi() print(f(n, n, x, 0))