# -*- coding: utf-8 -*-
"""
Created on Mon Apr 19 19:05:03 2021

@author: hp
"""

t=int(input())

    

for i in range(t):
    n,m=map(int,input().split())
    l=[]
    for x in str(n):
        l.append(int(x))
    l[:]=map(lambda x:str(x+m),l)
    c=len(str(int("".join(l))))%(10**9+7)
    print(c)