#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 1;
long long dp[10][N];
long long f(long long a, long long m) {
  if (m == 0) {
    return 1;
  }
  if (dp[a][m] != -1) {
    return dp[a][m];
  }
  if (a < 9) {
    return dp[a][m] = f(a + 1, m - 1);
  }
  return dp[a][m] = f(1, m - 1) + f(0, m - 1);
}
void solve() {
  long long n, m;
  string s;
  cin >> s >> m;
  long long ans = 0;
  for (auto u : s) {
    ans += f(u - '0', m);
    ans %= mod;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  memset(dp, -1, sizeof(dp));
  while (t--) {
    solve();
  }
  return 0;
}
