#include <bits/stdc++.h>
using namespace std;
template <typename Head>
void print(Head&& head) {
  cout << head << '\n';
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail... tail) {
  cout << head << " ";
  print(tail...);
}
long long int mceil(long long int a, long long int b) {
  return (a / b + (a % b != 0));
}
long long int mfloor(long long int a, long long int b) { return (a / b); }
long long modmul(long long a, long long b, long long MOD = 1000000007) {
  return ((a % MOD) * (b % MOD)) % MOD;
}
long long modadd(long long a, long long b, long long MOD = 1000000007) {
  return ((a % MOD) + (b % MOD) + MOD) % MOD;
}
long long modsub(long long a, long long b, long long MOD = 1000000007) {
  return ((a % MOD) - (b % MOD) + MOD) % MOD;
}
long long int fastexpo(long long int a, long long int b,
                       long long int MOD = 1000000007) {
  a = a % MOD;
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * 1ll * a) % MOD;
    a = (a * 1ll * a) % MOD;
    b = b / 2;
  }
  return ans;
}
vector<int> all_div[200001];
void alldivisors() {
  for (int i = 1; i <= 200000; ++i) {
    for (int j = i; j <= 200000; j += i) all_div[j].push_back(i);
  }
}
bool ispower2(long long int n) { return (n and (n & (n - 1)) == 0); }
long long int summ(long long int n) {
  long long int sum = 0;
  while (n) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
long long int myfloor(long long int n, long long int k) {
  long long int ans = n / k;
  if (n % k and n < 0) ans--;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int ans[200050];
  ans[0] = 1;
  vector<long long int> a(10, 0);
  a[0]++;
  for (long long int j = 1; j < 200050; j++) {
    vector<long long int> b(10, 0);
    long long int sum = 0;
    for (long long int i = 0; i < 10; i++) {
      if (i < 9) {
        b[i + 1] += a[i];
      } else if (i == 9) {
        b[1] += a[9];
        b[0] += a[9];
      }
    }
    for (long long int i = 0; i < 10; i++) sum += b[i];
    ans[j] = sum;
    a = b;
  }
  long long int tt = 1;
  cin >> tt;
  for (long long int ii = 0; ii < tt; ii++) {
    long long int n, m;
    cin >> n >> m;
    long long int result = 0;
    while (n) {
      long long int z = n % 10;
      result = modadd(result, ans[z + m]);
      n /= 10;
    }
    print(result);
  }
  return 0;
}
