#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9 + 7;
const int64_t LG = 2e5 + 100;
int64_t ans[LG];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int64_t m[15] = {0};
  m[0] = 1;
  ans[0] = 1;
  for (int64_t i = 0; i <= LG - 50; i++) {
    int64_t ne[15] = {0};
    for (int64_t j = 0; j <= 8; j++) {
      int64_t cnt = m[j];
      ne[j + 1] += cnt;
    }
    int64_t cnt = m[9];
    ne[0] += cnt;
    ne[1] += cnt;
    for (int64_t j = 0; j <= 9; j++) {
      m[j] = ne[j];
      ans[i + 1] += m[j];
    }
  }
  int64_t t;
  cin >> t;
  while (t--) {
    int64_t n, c;
    cin >> n >> c;
    int64_t an = 0;
    while (n) {
      int64_t l = n % 10;
      an = (an + ans[c + l]) % mod;
      n = n / 10;
    }
    cout << an << '\n';
  }
  return 0;
}
