#include <bits/stdc++.h>
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
vector<long long int> dp(200001, 0);
long long int mod = 1000000007;
void solve() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> ans(10, 0);
  long long int finalans = 0;
  string str = to_string(n);
  for (char c : str) {
    int index = c - '0';
    ans[index] = (ans[index] + 1) % mod;
  }
  for (int i = 0; i < 10; i++) {
    finalans = (finalans + (ans[i] * dp[m + i]) % mod) % mod;
  }
  cout << finalans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int j = 0; j <= 9; j++) dp[j] = 1;
  for (int j = 10; j <= 200000; j++) dp[j] = (dp[j - 10] + dp[j - 9]) % mod;
  int tc;
  cin >> tc;
  for (int t = 1; t <= tc; t++) {
    solve();
  }
}
