package main import . "fmt" import . "os" import bf "bufio" import . "math/big" func main() { rd:=bf.NewReader(Stdin) wr:=bf.NewWriter(Stdout) var t int Fscan(rd,&t) one:=NewInt(1) ten:=NewInt(10) mod:=NewInt(998244353) x,z:=new(Int),new(Int) for ;t>0;t-- { var n,m int64 Fscan(rd,&n,&m) if n/m%2==0 { z.Exp(ten,z.SetInt64(n%m),mod) z.Add(z,mod).Sub(z,one).Mod(z,mod) } else { x.Exp(ten,x.SetInt64(m),mod) x.Add(x,mod).Add(x,mod) z.Exp(ten,z.SetInt64(n%m),mod) z.Sub(x,z).Sub(z,one).Mod(z,mod) } Fprintln(wr,z) } wr.Flush() }