Q=int(input()) for _ in range(Q): N,M=map(int,input().split()) mod=998244353 k=N//M x=N%M p=pow(10,x,mod) if k%2==0: result=p-1 result%=mod else: result=-p-1 result%=mod print(result)