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

public class AddOne {
    static int dp[] = new int[20069];
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        /*for(int i = 0; i < 20069; i++) {
            if(i <= 9)
                dp[i] = 1;
            else {
                dp[i] = dp[i-10] + dp[i-9] % 1000000007;
            }
        }*/
        int t = sc.nextInt();
        while(t-- > 0) {
            int n = sc.nextInt();
            int o = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                int d = n % 10;
                n = n/10;
                sum += dp[d + o] % 1000000007;
            }
            
            System.out.println(sum);
        }
    }
}

