#include <bits/stdc++.h>
using namespace std;
const long long M = 10000000007;
const long long N = 1001;
void print(long long arr[], long long n) {
  for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  cout << endl;
}
void print(int arr[], int n) {
  for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  cout << endl;
}
void print(int arr[], long long n) {
  for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  cout << endl;
}
void print(vector<long long> arr, long long n) {
  for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  cout << endl;
}
vector<long long> pr;
bool prime[1000001];
void SieveOfEratosthenes() {
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= 1000000; i += p) prime[i] = false;
    }
  }
  prime[1] = false;
  for (long long p = 2; p <= 1000000; p++)
    if (prime[p]) pr.push_back(p);
}
long long power(long long a, long long n) {
  long long res = 1, mod = M;
  while (n) {
    if (n % 2) res = (res * a) % mod;
    a = (a * a) % mod;
    n = n / 2;
  }
  return res;
}
long long spf[100001];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 100001; i++) spf[i] = i;
  for (long long i = 4; i < 100001; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 100001; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 100001; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
vector<long long> getFactorization(long long x) {
  vector<long long> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
vector<long long> fact;
void calculate_factorials(long long n) {
  fact.resize(n + 1, 1);
  long long ans = 1;
  for (long long i = 1; i < n + 1; i++) {
    ans = ((ans % M) * (i % M)) % M;
    fact[i] = ans;
  }
}
void init_code() {}
long long arr[10][200001];
long long cal(long long n, long long m) {
  if (m < 10 - n) return 1;
  if (arr[n][m] != 0) return arr[n][m];
  long long ans = (cal(1, m - (10 - n)) % M + cal(0, m - (10 - n)) % M + M) % M;
  return arr[n][m] = ans;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long ct = 0;
  while (n) {
    long long d = n % 10;
    ct += cal(d, m);
    n /= 10;
  }
  cout << (((ct % M) + M) % M) << endl;
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  }
  init_code();
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
