import java.util.Scanner;

//https://codeforces.com/contest/1513/problem/C
public class Solution {

    private static long [] dp;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        formDp();
        for (int i = 0; i < n; i++) {

            String[] s = sc.nextLine().split(" ");
            int m = Integer.valueOf(s[1]);
            int k = Integer.valueOf(s[0]);
            long count = 0;
            int val, check;
            while (k > 0) {
                val = k%10;
                check = m + val - 9;
                count = (count + (check < 0 ? 1 : dp[check]));
                k = k/10;
            }
            count = count%1000000007;
            System.out.println(count);
        }
    }

    private static void formDp() {

        dp = new long [200002];

        dp[0] = 1;
        dp[1] = 2;
        dp[2] = 2;
        dp[3] = 2;
        dp[4] = 2;
        dp[5] = 2;
        dp[6] = 2;
        dp[7] = 2;
        dp[8] = 2;
        dp[9] = 2;

        for (int i = 10; i <= 200001; i++){
            dp[i] = ((dp[i-9] + dp[i-10]))%1000000007;
        }
        System.out.println(dp[200001]);
    }
}