#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2e5 + 100;
const int N = 1002;
const long long mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
long long a[MAXN];
long long c[10];
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  c[0] = 1;
  a[0] = 1;
  for (int i = 1; i <= MAXN; ++i) {
    long long tt = c[9];
    for (int j = 9; j > 0; --j) {
      c[j] = c[j - 1];
    }
    c[0] = tt;
    c[1] += tt;
    a[i] = (tt + a[i - 1]) % mod;
  }
  while (T--) {
    int n, m;
    cin >> n >> m;
    if (!n) {
      cout << a[m] << '\n';
      continue;
    }
    long long ans = 0;
    while (n) {
      int t = n % 10;
      n /= 10;
      ans = (ans + a[m + t]) % mod;
    }
    cout << ans << '\n';
  }
}
