

import java.io.*;
import java.util.*;

public class Table {
    static int mod=1000000000+7;
    static int[][] dp = new int[10][200001];
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        for(int i=0;i<10;i++){
            dp[i][0]=1;
        }
        for(int j=1;j<200001;j++){
            for(int i=0;i<10;i++){
                if(i!=9)dp[i][j]=dp[i+1][j-1];
                else dp[i][j]=(dp[1][j-1]+dp[0][j-1])%mod;
            }
        }
        StringBuilder sb = new StringBuilder();
        while (t-->0){
            long cnt=0;
            int n=sc.nextInt();
            int m=sc.nextInt();
            while (n>0){
                cnt+=dp[n%10][m]%mod;
                n/=10;
            }
            sb.append(cnt+"\n");
        }
        System.out.println(sb.toString());
    }
}