#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long N = 2e5 + 5;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(16);
  long long t, ans = 0, n, m;
  vector<long long> f(N, 0LL);
  cin >> t;
  for (long long i = 0; i < 10; i++) {
    f[i] = 1;
  }
  for (long long i = 10; i < N; i++) {
    f[i] = (f[i - 10] + f[i - 9]) % mod;
  }
  for (long long i = 0; i < t; i++) {
    ans = 0;
    cin >> n >> m;
    while (n) {
      ans = ans + f[n % 10 + m];
      n /= 10;
    }
    cout << ans % mod << "\n";
  }
  return 0;
}
