#include <bits/stdc++.h>
using namespace std;
int b[11][11][200010];
const long long mod = 1e9 + 7;
int main() {
  int t;
  for (int i = 0; i < 10; i++) {
    b[i][i][0] = 1;
    for (int j = 1; j <= 200000; j++) {
      for (int k = 0; k < 9; k++) {
        b[i][k + 1][j] = b[i][k][j - 1];
      }
      b[i][0][j] += b[i][9][j - 1];
      b[i][1][j] += b[i][9][j - 1];
    }
  }
  scanf("%d", &t);
  while (t--) {
    long long n;
    scanf("%lld", &n);
    int m;
    scanf("%d", &m);
    long long sum = 0;
    while (n) {
      for (int i = 0; i < 10; i++) {
        sum = sum + b[n % 10][i][m];
        sum = sum % mod;
      }
      n = n / 10;
    }
    printf("%lld\n", sum);
  }
}
