#include <bits/stdc++.h>
using namespace std;
int const Mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T, n, m;
  long long a[200011];
  for (int i = 0; i < 10; i++) a[i] = 1;
  for (int i = 10; i < 200011; i++) a[i] = (a[i - 9] + a[i - 10]) % Mod;
  cin >> T;
  while (T--) {
    cin >> n >> m;
    long long ans = 0;
    while (n > 0) {
      ans += a[n % 10 + m] % Mod;
      n /= 10;
    }
    cout << ans << endl;
  }
}
