#include <bits/stdc++.h>
using namespace std;
long long int dp[200005][12], M = 1e9 + 7;
long long int check(long long int m, long long int x) {
  if (m <= 0) return 1;
  if (dp[m][x] != -1) return dp[m][x];
  if (x == 9) {
    dp[m][x] = (check(m - 1, 1) % M + check(m - 1, 0) % M) % M;
  } else {
    dp[m][x] = check(m - 1, x + 1);
  }
  return dp[m][x] % M;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, k, p, q, r, s, t;
  for (i = 0; i < 200005; i++) {
    for (j = 0; j < 12; j++) dp[i][j] = -1;
  }
  cin >> t;
  while (t--) {
    cin >> p >> r;
    q = 0;
    while (p > 0) {
      q = (q % M + check(r, p % 10) % M);
      p = p / 10;
    }
    cout << q << "\n";
  }
}
