#include <bits/stdc++.h>
using namespace std;
const unsigned int mod = 1e9 + 7;
const unsigned int LEN = 2 * 1e5 + 10;
signed main() {
  unsigned int t;
  cin >> t;
  vector<unsigned int> a(10), b(10);
  vector<unsigned int> prec(LEN);
  a[0] = 1;
  vector<unsigned int> *state = &a, *oldstate = &b, *tmp = NULL;
  for (unsigned int i = 0; i < LEN; i++) {
    tmp = oldstate;
    state = oldstate;
    oldstate = tmp;
    for (unsigned int j = 0; j < 10; j++) {
      if (j != 9) {
        (*state)[j + 1] = (*oldstate)[j];
        (*state)[j + 1] %= mod;
      } else {
        (*state)[0] = (*oldstate)[j];
        (*state)[1] += (*oldstate)[j];
        (*state)[0] %= mod;
        (*state)[1] %= mod;
      }
    }
    unsigned int length = 0;
    for (unsigned int j = 0; j < 10; j++) {
      length += (*state)[j];
    }
    length %= mod;
    prec[i] = length;
  }
  while (t--) {
    unsigned int m;
    string n;
    cin >> n >> m;
    unsigned int ans = 0;
    m--;
    for (unsigned int i = 0; i < n.size(); i++) {
      unsigned int d = n[i] - '0';
      ans += prec[d + m];
      ans %= mod;
    }
    cout << ans << '\n';
  }
  return 0;
}
