#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, MOD = 1e9 + 10;
long long dp[N];
int main() {
  for (int i = 0; i < 9; i++) dp[i] = 2;
  dp[9] = 3;
  for (int i = 10; i < N; i++) {
    dp[i] = (dp[i - 9] + dp[i - 10]) % MOD;
  }
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    scanf("%d%d", &n, &m);
    long long ans = 0;
    while (n > 0) {
      int x = n % 10;
      ans += ((m + x < 10) ? 1 : dp[m + x - 10]);
      ans %= MOD;
      n /= 10;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
