#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const int MAX_N = 2e5 + 10;
ll dp[MAX_N][10];
ll sum[MAX_N];
void init() {
  dp[0][0] = dp[0][1] = 1;
  sum[0] = 2;
  for (int i = 1; i < MAX_N; i++) {
    for (int k = 0; k < 10; k++) dp[i][(k + 1) % 10] = dp[i - 1][k];
    dp[i][1] += dp[i - 1][9];
    sum[i] = (sum[i - 1] + dp[i - 1][9]) % MOD;
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  ll res = 0;
  while (n) {
    int x = 10 - n % 10;
    if (m < x)
      res = res + 1;
    else
      res = res + sum[m - x];
    res %= MOD;
    n /= 10;
  }
  cout << res << endl;
}
int main() {
  init();
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
