#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, maxn = 2e5 + 7;
int t, n, m;
long long a[maxn][10];
long long now = 1;
int main() {
  a[0][0] = 1;
  for (int i = 1; i < maxn; ++i) {
    for (int j = 0; j <= 8; ++j) a[i][j + 1] = a[i - 1][j];
    a[i][0] = a[i - 1][9];
    a[i][1] += a[i - 1][9];
    if (a[i][1] >= mod) a[i][1] %= mod;
  }
  for (scanf("%d", &t); t--;) {
    scanf("%d%d", &n, &m);
    long long ans = 0;
    while (n) {
      int t = n % 10;
      for (int i = 0; i < 10; ++i) {
        ans = ans + a[m + t][i];
        if (ans >= mod) ans %= mod;
      }
      n /= 10;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
