dp = [1 for i in range(10)]
for i in range(10, 200100):
	dp.append((dp[i - 9] + dp[i - 10]) % 1000000007)

t = int(input())
for ti in range(t):
	n, m = [int(i) for i in input().split(' ')]
	td = 0
	for i in range(10):
		td += dp[(n % 10) + m]
		td %= 1000000007
		n //= 10
	print(td)