#include <bits/stdc++.h>
using namespace std;
long long xx[] = {0, 0, 1, 1, 1, -1, -1, -1};
long long yy[] = {-1, 1, -1, 0, 1, -1, 0, 1};
long long power(long long x, long long y) {
  if (y == 0) return 1;
  long long temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
long long m = 2 * (1e5) + 10;
vector<long long> pre(m, 0);
void precompute() {
  vector<long long> count(11, 0);
  count[0] = 1;
  pre[0] = 1;
  for (long long i = 1; i <= m; i++) {
    for (long long i = 9; i >= 0; i--) {
      if (i == 9) {
        count[10] = count[9];
        count[9] = 0;
      } else {
        count[i + 1] = count[i];
        count[i] = 0;
      }
    }
    if (count[10]) {
      count[1] += count[10];
      count[0] += count[10];
      count[10] = 0;
    }
    for (long long j = 0; j < 10; j++) pre[i] += count[j];
  }
}
void solve() {
  long long n, num;
  cin >> num >> n;
  long long ans = 0;
  long long mod = 1e9 + 7;
  while (num) {
    ans = ans + pre[n + (num % 10)];
    ans = ans % mod;
    num /= 10;
  }
  cout << ans;
}
int32_t main() {
  std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  precompute();
  long long t = 0;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
}
