#include <stdio.h>

long long power_mod (long long a, long long b, long long mod_num) {
  long long ans = 1LL;
  
  if (b > 0LL) {
    ans = power_mod(a, b/2LL, mod_num);
    ans = (ans * ans) % mod_num;
    if (b%2LL == 1LL) {
      ans = (ans * (a % mod_num)) % mod_num;
    }
  }
  
  return ans;
}

int main () {
  int t = 0;
  long long n = 0LL;
  long long m = 0LL;
  
  int res = 0;
  
  long long mod_num = 998244353LL;
  
  res = scanf("%d", &t);
  while (t > 0) {
    res = scanf("%lld", &n);
    res = scanf("%lld", &m);
    n %= 2LL*m;
    if (n > m) {
      printf("%lld\n", (((power_mod(10LL, 2LL*m-n, mod_num)+mod_num-1LL)%mod_num)*power_mod(10LL, n-m, mod_num))%mod_num);
    } else {
      printf("%lld\n", (mod_num-1LL+power_mod(10LL, n, mod_num))%mod_num);
    }
    t--;
  }
  
  return 0;
}