#include <bits/stdc++.h>
using namespace std;
int64_t t, n, m, i, j, k, s, b, c, p, x, y, ans;
string s1, s2;
const int64_t M = 10e9 + 7;
bool bo;
int64_t dp[200005] = {0};
void solve() {
  cin >> n >> m;
  ans = 0;
  while (n != 0) {
    y = n % 10;
    n = n / 10;
    if (m >= 10 - y)
      ans += dp[m - (10 - y)];
    else
      ans += 1;
  }
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  t = 1;
  cin >> t;
  int64_t a[10] = {0};
  a[0] = 1;
  a[1] = 1;
  dp[0] = 2;
  for (i = 1; i < 200005; i++) {
    dp[i] = (dp[i - 1] + a[9]) % M;
    x = a[9];
    for (j = 9; j > 0; j--) a[j] = a[j - 1];
    a[0] = x;
    a[1] = (a[1] + x) % M;
  }
  while (t--) solve();
}
