T = int(input()) mod = 998244353 for _ in range(T): N, M = map(int, input().split()) p, q = divmod(N, M) if p % 2 == 1: print((pow(10, M, mod)-pow(10, q, mod))%mod) else: print((pow(10, q, mod)-1)%mod)