#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
long long dp[200100] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
int main() {
  int T;
  cin >> T;
  for (int i = 10; i <= 200000; i++) dp[i] = (dp[i - 9] + dp[i - 10]) % mod;
  cout << dp[93] << ' ' << dp[92] << endl;
  while (T--) {
    int n, k;
    cin >> n >> k;
    long long tot = 0;
    while (n) {
      long long t = n % 10;
      n /= 10;
      int m = k;
      if (m < 9 - t) {
        tot++;
        tot = tot % mod;
        continue;
      } else {
        tot += dp[m];
        tot++;
        tot = tot % mod;
      }
    }
    cout << tot << endl;
  }
  return 0;
}
