#include <bits/stdc++.h>
using namespace std;
const int N = 2 * (1e5) + 15;
const int mod = 1e9 + 7;
int dp[N];
int main() {
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 1;
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;
  dp[6] = 1;
  dp[7] = 1;
  dp[8] = 1;
  dp[9] = 1;
  dp[10] = 2;
  dp[11] = 2;
  dp[12] = 2;
  dp[13] = 2;
  dp[14] = 2;
  dp[15] = 2;
  for (int i = 16; i < N; i++) {
    dp[i] = (dp[i - 1] + dp[i - 9] - dp[i - 11]) % mod;
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long ans = 0;
    while (n > 0) {
      int temp = n % 10;
      ans = (ans + dp[temp + m]) % mod;
      n = n / 10;
    }
    cout << ans << "\n";
  }
  return 0;
}
