import sys input = sys.stdin.readline T = int(input()) mod = 998244353 for _ in range(T): N, M = map(int, input().split()) N %= 2 * M if N >= M: ans = - pow(10, N - M, mod) - 1 else: ans = pow(10, N, mod) - 1 print(ans % mod)