#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int l[200100];
  int cnt[10];
  int tmp[10];
  l[0] = 1;
  cnt[0] = 1;
  for (int r = 1; r <= 200100; r++) {
    std::copy(cnt, cnt + 10, tmp);
    cnt[0] = tmp[9];
    cnt[1] = (tmp[0] + tmp[9]) % 1000000007;
    for (int i = 2; i < 10; i++) {
      cnt[i] = tmp[i - 1];
    }
    for (int i = 0; i < 10; i++) {
      l[r] += cnt[i];
      l[r] %= 1000000007;
    }
  }
  int T;
  cin >> T;
  for (int case_num = 1; case_num <= T; case_num++) {
    int n;
    cin >> n;
    int m;
    cin >> m;
    int ans = 0;
    int d;
    while (n > 0) {
      d = n % 10;
      ans += l[m + d];
      ans %= 1000000007;
      n /= 10;
    }
    cout << ans << '\n';
  }
  return 0;
}
