#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> adj;
map<long, bool> vis, viss;
vector<long long> rnk, parent, sz;
int spf[1000000 + 1];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(nullptr);
  long long int t, temp;
  long long int cnt[10]{};
  long long int dp[200010];
  dp[0] = 1;
  cnt[0]++;
  for (long long int k = 1; k <= 200000; k++) {
    dp[k] = dp[k - 1];
    long long int cntchange[10]{};
    for (long long int i = 0; i <= 8; i++) {
      if (cnt[i]) {
        cntchange[i + 1] += cnt[i] % 1000000007;
        cntchange[i] += -cnt[i] % 1000000007;
        cntchange[i] %= 1000000007;
        cntchange[i + 1] %= 1000000007;
        if (cntchange[i] < 0) cntchange[i] += 1000000007;
      }
    }
    if (cnt[9]) {
      cntchange[9] += -cnt[9];
      cntchange[9] %= 1000000007;
      if (cntchange[9] < 0) cntchange[9] += 1000000007;
      cntchange[0] += cnt[9];
      cntchange[1] += cnt[9];
      cntchange[0] %= 1000000007;
      cntchange[1] %= 1000000007;
    }
    for (long long int i = 0; i <= 9; i++) {
      cnt[i] += cntchange[i] % 1000000007;
      dp[k] += cntchange[i] % 1000000007;
      dp[i] %= 1000000007;
      cnt[i] %= 1000000007;
    }
  }
  cin >> t;
  while (t--) {
    long long int n, m;
    long long int ans = 0;
    cin >> n >> m;
    while (n > 0) {
      long long int dig = n % 10;
      long long int mm = m + dig;
      ans += dp[mm] % 1000000007;
      ans %= 1000000007;
      n = n / 10;
    }
    cout << ans << "\n";
  }
  return 0;
}
