import java.util.Scanner;

public class AddOne {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T-- > 0) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			int l = 0;
			while(N != 0) {
				int d = N % 10;
				l += String.valueOf(d + M).length();
				N /= 10;
			}
			System.out.println(l % 1000000007);
		}
		sc.close();
	}
}
