#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long MAXX = 2e5 + 5;
long long t, n, m;
vector<long long> s(MAXX, 0);
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  s[0] = 1;
  vector<long long> v(15, 0);
  vector<long long> tp(15, 0);
  v[9] = 1;
  long long sum = 1;
  for (long long m = 1; m <= 200000; m++) {
    for (long long i = 1; i < 10; i++) {
      tp[i] = v[i - 1];
    }
    sum += v[9];
    v[0] = v[9];
    v[1] = tp[1] + v[9];
    for (long long i = 2; i < 10; i++) {
      v[i] = tp[i];
    }
    sum %= mod;
    sum += mod;
    sum %= mod;
    s[m] = sum;
  }
  while (t--) {
    cin >> n >> m;
    vector<long long> d(15, 0);
    while (n) {
      d[n % 10]++;
      n /= 10;
    }
    long long ans = 0;
    for (long long i = 0; i <= 9; i++) {
      long long h = 9 - i;
      if (h >= m) {
        ans += d[i];
        continue;
      }
      long long g = m - h;
      ans += (d[i] * s[g]);
      ans %= mod;
    }
    cout << ans << endl;
  }
  return 0;
}
