def fast_exponentiation(a, b, n): result = 1 a %= n while b > 0: if b % 2 == 1: result = (result * a) % n a = (a * a) % n b //= 2 return result for _ in range(int(input())): n,m=map(int,input().split()) s=fast_exponentiation(10,n%(2*m),998244353) if s==0: print(998244352) else: print(s-1)