mod = 998244353 t = int(input()) ans = 0 for i in range(t): n, m = map(int, input().split()) n %= m*2 if n <= m: print((pow(10, n, mod) - 1) % mod) else: print((pow(10, m*2, mod) - 1) * pow(10, n - m, mod) % mod)