#include <bits/stdc++.h>
using namespace std;
int t[200055];
int f(int x) {
  if (t[x] != 0) return t[x];
  return t[x] = (f(x - 10) + f(x - 9)) % ((int)1e9 + 7);
}
int main() {
  for (int i = 0; i <= 9; i++) t[i] = 1;
  for (int i = 10; i <= 18; i++) t[i] = 2;
  f(200010);
  int T, n, m;
  cin >> T;
  while (T--) {
    scanf("%d%d", &n, &m);
    int ans = 0;
    while (n > 0) {
      int l = n % 10;
      ans += t[m + l];
      ans %= (int)(1e9 + 7);
      n /= 10;
    }
    cout << ans << endl;
  }
  return 0;
}
