#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
double roundd(double x, int k) {
  x = (int)(x * pow(10, k) + 0.5);
  x = (double)(x / pow(10, k));
  return x;
}
int DP[100000 + 1];
void solve() {
  int n, m, x, y;
  cin >> n >> m;
  long long res = 0;
  x = n;
  while (x > 0) {
    int d = x % 10;
    x = x / 10;
    if ((m - (10 - d)) >= 0) {
      res = (res + DP[m - (10 - d)]) % 1000000007;
    } else {
      res = (res + 1) % 1000000007;
    }
  }
  cout << res << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  for (long long i = 0; i < 10; i++) DP[i] = 2;
  DP[9]++;
  for (int i = 10; i <= (100000 + 1); i++) {
    DP[i] = (DP[i - 9] + DP[i - 10]) % 1000000007;
  }
  while (t--) {
    solve();
  }
  return 0;
}
