#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long mxn = 2e5 + 10, mod = 1e9 + 7;
long long tc, n, k, ans, cnt[11], new_cnt[11], dp[11][mxn];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  cout.setf(ios::fixed);
  cout.precision(0);
  cin >> tc;
  for (long long i = 0; i < 10; i++) {
    cnt[i] = dp[i][0] = 1;
    for (long long k = 1; k < mxn; k++) {
      for (long long j = 1; j < 10; j++) {
        new_cnt[j] = cnt[j - 1];
      }
      new_cnt[0] = cnt[9];
      new_cnt[1] += cnt[9];
      for (long long j = 0; j < 10; j++) {
        cnt[j] = new_cnt[j];
        new_cnt[j] = 0;
        dp[i][k] += cnt[j];
        dp[i][j] %= mod;
      }
    }
    for (long long j = 0; j < 10; j++) cnt[j] = 0;
  }
  while (tc--) {
    cin >> n >> k;
    ans = 0;
    while (n != 0) {
      ans += dp[n % 10][k];
      n /= 10;
    }
    cout << ans << '\n';
  }
  return 0;
}
