#include <bits/stdc++.h>
using namespace std;
long long p = 1000000007;
long long M = 200001;
int main() {
  long long dp[M];
  for (long long i = 0; i < 9; i++) dp[i] = 2;
  dp[9] = 3;
  for (long long i = 10; i < M; i++) dp[i] = dp[i - 9] + dp[i - 10];
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n, m, ans = 0;
    cin >> n >> m;
    while (n > 0) {
      if ((n % 10 + m) < 10)
        ans = (ans + 1) % p;
      else
        ans = (ans + dp[n % 10 + m - 10]) % p;
      n /= 10;
    }
    cout << ans << endl;
  }
  return 0;
}
