#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 9;
const int MOD = 1e9 + 7;
const int mod = 999998639;
inline long long qpow(long long b, long long e, long long m = MOD) {
  long long a = 1;
  for (; e; e >>= 1, b = b * b % m)
    if (e & 1) a = a * b % m;
  return a;
}
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long d = exgcd(b, a % b, x, y);
  long long z = x;
  x = y, y = z - y * (a / b);
  return d;
}
long long dp[maxn + 10][19];
long long orz[maxn];
int main() {
  dp[0][1] = 1;
  for (int i = 1; i <= maxn; i++) {
    for (int j = 0; j < 10; j++) {
      dp[i][j] = dp[i - 1][j - 1];
    }
    dp[i][0] += dp[i - 1][9];
    dp[i][1] += dp[i - 1][9];
    for (int j = 0; j < 10; j++) {
      dp[i][j] %= MOD;
      orz[i] += dp[i][j];
      orz[i] %= MOD;
    }
  }
  int _;
  while (scanf("%d", &_) != EOF) {
    while (_--) {
      int n, m;
      scanf("%d%d", &n, &m);
      vector<int> ve;
      int oo = n;
      while (oo) {
        ve.push_back(oo % 10);
        oo /= 10;
      }
      long long ans = 0;
      for (int i = 0; i < ve.size(); i++) {
        ans += orz[m - 1 + ve[i]];
        ans %= MOD;
      }
      printf("%lld\n", max(ans, (long long)ve.size()));
    }
  }
}
