#include <bits/stdc++.h>
using namespace std;
vector<int> summ(10000001, 0);
vector<int> res(10000001, -1);
int dp[200001][10];
long long p = 1000000007;
void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  long long ans = 0;
  while (n) {
    ans += dp[m][n % 10];
    ans %= p;
    n /= 10;
  }
  printf("%d\n", ans % p);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  memset(dp, 0, sizeof(dp));
  int t;
  cin >> t;
  for (int i = 0; i < 10; i++) dp[0][i] = 1;
  for (int i = 1; i <= 200000; i++) {
    for (int j = 0; j < 10; j++) {
      int x = 10 - j;
      if (x > i)
        dp[i][j] = 1;
      else {
        dp[i][j] = (dp[i - x][1] + dp[i - x][0]) % p;
      }
    }
  }
  while (t--) {
    solve();
  }
}
