#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long int mod = 1000000007;
  long int t, n, m, i, j, x, ans;
  cin >> t;
  long int dp[200000 + 11][10];
  long int dpc[200000 + 11];
  dp[0][0] = 1;
  for (i = 0; i < 200000 + 10; i++) {
    dp[i + 1][0] = dp[i][9] % mod;
    dp[i + 1][1] = dp[i][9] % mod;
    for (j = 0; j < 9; j++) {
      dp[i + 1][j + 1] += dp[i][j];
      dp[i + 1][j + 1] %= mod;
    }
    for (j = 0; j < 10; j++) {
      dpc[i] += dp[i][j] % mod;
      dpc[i] %= mod;
    }
  }
  for (i = 0; i < t; i++) {
    scanf("%ld %ld", &n, &m);
    ans = 0;
    while (n != 0) {
      x = n % 10;
      ans += dpc[m + x];
      ans %= mod;
      n /= 10;
    }
    printf("%ld\n", ans);
  }
  return 0;
}
