import math as m
test = int(input())
def operate(n):
	arr = n.split()
	for i in range(len(arr)):
		arr[i] = str(int(arr[i]) + 1)
	return ''.join(arr)
	
while test > 0:
	test -= 1
	num, op = input().split()
	for i in range(int(op)):
		num = operate(num)
	print(int(num) % (m.pow(10,9) + 7))
