tests = input()

input_arrays = []

for test in range(int(tests)):
	input_arrays.append([int(x) for x in input().split()])

def operate(number, ops):
	num = [int(m) for m in list(str(number))]
	for x in range(ops):
		for y in range(len(num)):
			num[y] += 1

	number = [str(n) for n in num]

	return ''.join(number)

for array in input_arrays:
	print(len(operate(array[0], array[1])))