T = int(input()) MOD = 998244353 for _ in range(T): N, M = map(int, input().split()) N %= (M*2) ans = 0 if N <= M: ans = (pow(10, N, MOD)-1)%MOD else: ans = ((pow(10, M, MOD)-1)-(pow(10, N%M, MOD)-1))%MOD print(ans)