mod = 998244353 for _ in [0]*int(input()): 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-n, mod) - 1) * pow(10, n-m, mod) % mod)