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