<>;@t=<>;map{@f=(1,$_);/ .* /,push@f,$a=($`<2?$f[$&]+$f[$']:($`<3?$&:$f[$&])*$f[$'])%998244353for@t;print$a,$/}glob pop@t