$a=1;$`-1&&push@d,($a+=$d[-$`])%=998244353for<>!~$"..$';print$a