#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 1e5 + 5;
const long long MOD = 1e9 + 7;
long long dp[MAXN][10];
int main() {
  int t;
  cin >> t;
  for (int i = 0; i <= 2 * 1e5; i++) {
    for (int j = 0; j <= 9; j++) {
      if (i == 0) {
        dp[i][j] = 1;
      } else {
        if (j == 9) {
          dp[i][j] = (dp[i - 1][1] + dp[i - 1][0]) % MOD;
        } else {
          dp[i][j] = dp[i - 1][j + 1];
        }
      }
    }
  }
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    int N, M;
    scanf("%d%d", &N, &M);
    int ans = 0;
    while (N) {
      ans = (ans + dp[M][N % 10]) % MOD;
      N /= 10;
    }
    printf("%d\n", ans);
  }
}
