#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long mod = 1000000007;
long long dp[N][10];
void cases() {
  long long n, m;
  cin >> n >> m;
  string s = to_string(n);
  long long p = s.size();
  long long ans = 0;
  for (long long i = 0; i < p; i++) ans += dp[m][s[i] - '0'] %= mod;
  cout << ans << "\n";
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  for (long long i = 0; i <= 9; i++) dp[0][i] = 1;
  for (long long i = 1; i < N; i++) {
    for (long long j = 0; j < 9; j++) dp[i][j] = dp[i - 1][j + 1];
    dp[i][9] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
  }
  for (long long i = 0; i < t; i++) {
    cases();
  }
  return 0;
}
