import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### mod = 998244353 for _ in range(ni()): n, m = na() n %= 2*m if n < m: print((pow(10, n, mod)-1)) else: print((pow(10, m, mod)-pow(10, n-m, mod)))