#include <bits/stdc++.h>
using namespace std;
long long mod = pow(10, 9) + 7;
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fast();
  int t;
  cin >> t;
  long long pre[200010];
  long long p = 0;
  long long count[10] = {0};
  count[0] = 1;
  while (p < 200010) {
    long long temp = count[9];
    for (int i = 9 - 1; i >= 0; --i) {
      count[i + 1] = count[i];
    }
    count[0] = temp % mod;
    count[1] = (count[1] + temp) % mod;
    for (int i = 0; i < 10; ++i) {
      pre[p + 1] = (pre[p + 1] + count[i]) % mod;
    }
    p++;
  }
  for (int _ = 0; _ < t; ++_) {
    string n;
    long long m;
    cin >> n >> m;
    long long ans = 0;
    for (int i = 0; i < n.size(); ++i) {
      ans = (ans + pre[m + n[i] - '0']) % mod;
    }
    cout << ans << '\n';
  }
}
