S = input R = range P = print def I(): return int(S()) def M(): return map(int, S().split()) def L(): return list(M()) def O(): return list(map(int, open(0).read().split())) def yn(b): print("Yes" if b else "No") biga = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" smaa = "abcdefghijklmnopqrstuvwxyz" mod = 998244353 for _ in R(I()): n, m = M() y, x = divmod(n, m) if y % 2 == 1: print((pow(10, m, mod) - 1 - pow(10, x, mod)) % mod) else: print((pow(10, x, mod) - 1) % mod)