#include <bits/stdc++.h>
using namespace std;
long long f[200010];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  vector<int> v;
  v.push_back(0);
  int tmp;
  for (int i = 1; i <= 9; i++) {
    f[i] = 1;
  }
  for (int i = 10; i <= 18; i++) {
    f[i] = 2;
  }
  f[19] = 3;
  for (int i = 20; i <= 200005; i++) {
    f[i] = (f[i - 9] + f[i - 10]) % 1000000007;
  }
  int t;
  cin >> t;
  while (t--) {
    long long ans = 0;
    long long x, k;
    cin >> x >> k;
    while (x) {
      long long tmp = x % 10;
      ans = (ans + f[k + tmp]) % 1000000007;
      x /= 10;
    }
    cout << ans << '\n';
  }
  return 0;
}
