import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

    private static final int mod = (int) 1e9 + 7;
    public static void main(String[] args) {
        FastScanner fs=new FastScanner();
        PrintWriter pr = new PrintWriter(System.out);
        int[][] counts = new int[10][200_001];
        for(int i = 0; i < 10; i++) counts[i] = simu(i, 200_001);
        int T=fs.nextInt();
        for (int tt=1; tt<=T; tt++) {
            int n = fs.nextInt();
            int m = fs.nextInt();
            long ans = 0;
            for(char c: ("" + n).toCharArray())
                ans += counts[c - '0'][m];
            pr.println(ans);
        }
        pr.flush();
        pr.close();
    }

    static int[] simu(int start, int steps) {
        int[] count = new int[10];
        int[] newCount = new int[10];
        int[] ans = new int[steps];
        count[start]++;
        int sum = 1;
        for(int i = 1; i < steps; i++) {
            Arrays.fill(newCount, 0);
            for(int j = 0; j < 9; j++) newCount[j + 1] = count[j];
            newCount[0] = count[9];
            newCount[1] = add(newCount[1], count[9]);
            sum = add(sum, count[9]);
            int[] temp = count;
            count = newCount;
            newCount = temp;
            ans[i] = sum;
        }
        return ans;
    }

    private static int add(int a, int b) {
        if(a + b >= mod) return a + b - mod;
        return a + b;
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long[] readLongArray(int n) {
            long[] a=new long[n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
