#include <bits/stdc++.h>
using namespace std;
inline bool valid(int x, int n) { return 0 <= x && x < n; }
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
template <typename T>
inline T pop(queue<T>& q) {
  T front = q.front();
  q.pop();
  return front;
}
template <typename T>
inline T gcd(T a, T b) {
  for (; b; a %= b, swap(a, b))
    ;
  return a;
}
template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
  if (b == 0) return {1, 0, a};
  T x, y, g;
  tie(x, y, g) = xgcd(b, a % b);
  return {y, x - (a / b) * y, g};
}
const long long int mod = 1e9 + 7;
long long int memo[200009];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  for (int i = 0; i < 10; i++) memo[i] = 1;
  for (int i = 10; i <= 2e5; i++) memo[i] = (memo[i - 10] + memo[i - 9]) % mod;
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int k;
    cin >> k;
    long long int rst = 0;
    while (n) {
      rst = (rst + memo[k + n % 10]) % mod;
      n /= 10;
    }
    cout << rst << "\n";
  }
}
