import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;



public class Solution {
	

 
  

 
    public static void main(String[] args) throws IOException {
         Scanner sc=new Scanner(System.in);
         Solution sol=new Solution();
         int t=sc.nextInt();
         for(int i=0;i<t;i++) {
        	 int in=sc.nextInt();
        	 String op=String.valueOf(in);
        	 int oper=sc.nextInt();
        	 int kl=op.length();
            int [][]dp=new int[kl+1][oper+1];
            for(int j=0;j<oper+1;j++) {
             dp[0][j]=0;
            }
            for(int j=1;j<kl+1;j++) {
            	dp[j][0]=Character.getNumericValue(op.charAt(j-1));
            //System.out.print(dp[j][0]);
            }
            for(int k=1;k<kl+1;k++) {
            	for(int j=1;j<oper+1;j++) {
            		dp[k][j]=dp[k][j-1]+1;
            	}
            	}
            int len=0;
          for(int gh=1;gh<kl+1;gh++) {
        	  String gg=String.valueOf(dp[gh][oper]);
        	  len+=gg.length();
          }
          System.out.println(len%(Math.pow(10, 9)+7));
         }
         
        
        
       
       
        
           
       
        }
                         
         }

	
    

