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