#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  vector<int> arr(200027, 1);
  vector<int> num(10, 0);
  num[0] = 1;
  arr[0] = 1;
  for (int i = 1; i < 200007; i++) {
    vector<int> new_num(10, 0);
    for (int j = 1; j < 10; j++) {
      new_num[j] = num[j - 1];
    }
    new_num[0] = num[9];
    new_num[1] = (new_num[1] + num[9]) % 1000000007;
    arr[i] = (arr[i - 1] + num[9]) % 1000000007;
    num = new_num;
  }
  while (t--) {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int cpy = n;
    while (cpy) {
      int digit = cpy % 10;
      ans = (ans + arr[k + digit]) % 1000000007;
      cpy /= 10;
    }
    cout << ans << endl;
  }
  return 0;
}
