import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.Vector.Unboxed as U

main = C.interact $ C.pack . show . sol . unfoldr (C.readInt . C.dropWhile (<'0'))

sol (n:s:as) = U.last $ foldr f (U.singleton 1 U.++ U.replicate s 0) as

f a = U.zipWith (\a b -> (a+b) `mod` p) <$> U.map (2*) <*> (U.replicate a 0 U.++)

p = 998244353 :: Int