#include <bits/stdc++.h>
using namespace std;
template <class T>
void inp(T& x) {
  cin >> x;
}
template <class H, class... T>
void inp(H& h, T&... t) {
  inp(h);
  inp(t...);
}
template <class A>
void inp(vector<A>& x) {
  for (auto& a : x) inp(a);
}
void deb_out() { cerr << endl; }
template <typename Head, typename... Tail>
void deb_out(Head H, Tail... T) {
  cerr << ' ' << H;
  deb_out(T...);
}
const long long int mod = 1e9 + 7;
const char nl = '\n';
const long long int scale = 12e10;
int dp[1000005];
void solve() {
  int i, j;
  long long int n, m, ans = 0;
  inp(n, m);
  while (n) {
    int d = n % 10;
    ans = (ans + dp[m + d]) % mod;
    n /= 10;
  }
  cout << ans << nl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  inp(t);
  int x = t;
  for (int i = 0; i < 1e6; i++) {
    if (i < 10)
      dp[i] = 1;
    else
      dp[i] = dp[i - 9] + dp[i - 10];
  }
  while (t--) {
    solve();
  }
  return 0;
}
