#include <bits/stdc++.h>
using namespace std;
long long dp[200000][10];
void preCalc() {
  long long nums[10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      nums[i] = 0;
    }
    nums[i] = 1;
    for (int j = 0; j < 20000; j++) {
      long long m = 0;
      for (int k = 0; k < 10; k++) {
        if (k == 9) {
          nums[0] = m;
          nums[1] += m;
        } else {
          if (k == 0) {
            m = nums[k + 1];
            nums[k + 1] = nums[k];
          } else {
            long long temp = nums[k + 1];
            nums[k + 1] = m;
            m = temp;
          }
        }
      }
      long total = 0;
      for (int j = 0; j < 10; j++) {
        total += nums[j];
        total %= 1000000007;
      }
      dp[j][i] = total;
    }
  }
}
int main() {
  int i;
  cin >> i;
  preCalc();
  while (--i) {
    int n, m;
    cin >> n >> m;
    long long total = 0;
    while (n >= 1) {
      total += dp[m][n % 10];
      n /= 10;
      total %= 1000000007;
    }
    cout << total << "\n";
  }
}
