#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M = 1010, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6;
using namespace std;
int a[N];
int sum[N];
int f[N][11];
int n, m;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int read() {
  int date = 0, w = 1;
  char c = 0;
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    date = date * 10 + c - '0';
    c = getchar();
  }
  return date * w;
}
long long qmi(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
bool cmp(int first, int second) { return first > second; }
void init() {
  f[0][0] = f[0][1] = 1;
  sum[0] = 2;
  for (int i = 1; i <= 200000; i++)
    for (int j = 0; j <= 9; j++) {
      if (j) f[i][j] = f[i - 1][j - 1];
      if (j == 0 || j == 1) f[i][j] = (1ll * f[i][j] + f[i - 1][9]) % mod;
      sum[i] = (1ll * sum[i] + f[i][j]) % mod;
    }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    a[0] = 0;
    while (n) {
      a[++a[0]] = n % 10;
      n /= 10;
    }
    long long ans = 0;
    for (int i = 1; i <= a[0]; i++) {
      int first = 10 - a[i];
      if (m < first)
        ans = (ans + 1) % mod;
      else
        ans = (ans + sum[m - first]) % mod;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
