{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns, BinaryLiterals, CPP, DerivingStrategies  #-}
{-# LANGUAGE DerivingVia, FlexibleContexts, FlexibleInstances       #-}
{-# LANGUAGE GeneralizedNewtypeDeriving, KindSignatures, LambdaCase #-}
{-# LANGUAGE MagicHash, MultiParamTypeClasses, MultiWayIf           #-}
{-# LANGUAGE NumericUnderscores, OverloadedStrings, PatternSynonyms #-}
{-# LANGUAGE RankNTypes, RecordWildCards, ScopedTypeVariables       #-}
{-# LANGUAGE StandaloneDeriving, TupleSections, TypeApplications    #-}
{-# LANGUAGE TypeFamilies, TypeInType, UnboxedTuples, ViewPatterns  #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.Reader
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bifunctor
import           Data.Bool
import qualified Data.ByteString                   as B
import qualified Data.ByteString.Builder           as B
import qualified Data.ByteString.Char8             as C
import qualified Data.ByteString.Internal          as B
import qualified Data.ByteString.Unsafe            as B
import           Data.Char
import qualified Data.Foldable                     as F
import           Data.Function
import           Data.Functor.Identity
import qualified Data.IntMap.Strict                as IM
import qualified Data.IntSet                       as IS
import qualified Data.List                         as L
import qualified Data.Map.Strict                   as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive
import           Data.Proxy
import           Data.Ratio
import           Data.Semigroup
import qualified Data.Set                          as S
import           Data.Tuple
import qualified Data.Vector                       as V
import qualified Data.Vector.Algorithms.Intro      as Intro
import qualified Data.Vector.Fusion.Stream.Monadic as MS
import qualified Data.Vector.Fusion.Bundle.Monadic as MB
import           Data.Vector.Fusion.Util
import qualified Data.Vector.Generic               as G
import qualified Data.Vector.Generic.Mutable       as GM
import qualified Data.Vector.Mutable               as VM
import qualified Data.Vector.Primitive             as P
import qualified Data.Vector.Primitive.Mutable     as PM
import qualified Data.Vector.Unboxed               as U
import qualified Data.Vector.Unboxed.Mutable       as UM
import           Debug.Trace
import           Foreign                           hiding (void)
import           GHC.Exts
import           GHC.TypeLits
import           System.IO
import           Unsafe.Coerce

#define MOD 1000000007

main :: IO ()
main = do
    [n, m] <- map read.words <$> getLine
    xs <- U.unfoldrN n (runParser int) <$> C.getLine
    ys <- U.unfoldrN m (runParser int) <$> C.getLine
    putStr.unwords.map show.U.toList $ solve n m xs ys

solve :: Int -> Int -> U.Vector Int -> U.Vector Int -> U.Vector Int
solve n m xs ys = convolute 998244353 3 xs ys

ntt
    :: Int          -- ^ prime (c * 2 ^ k + 1)
    -> Int          -- ^ primitive root
    -> U.Vector Int -- ^ n = 2 ^ i, n < 2 ^ k
    -> U.Vector Int
ntt p g f = runST $ do
    ff <- U.unsafeThaw $ U.unsafeBackpermute f
        $ U.generate n ((`unsafeShiftRL` (64 - logN)) . bitReverse)
    U.forM_ (U.iterateN logN (*2) 2) $ \m -> do
        let !unity = powMod g (quot (p - 1) m) p -- rem (p - 1) m == 0
        let !unities = U.iterateN (unsafeShiftRL m 1) ((`rem` p) . (* unity)) 1
        fix (\loop !k -> when (k < n) $ do
            flip U.imapM_ unities $ \j w -> do
                u <- UM.unsafeRead ff (k + j)
                t <- (* w) <$!> UM.unsafeRead ff (k + j + unsafeShiftRL m 1)
                UM.unsafeWrite ff (k + j) $ rem (u + t) p
                UM.unsafeWrite ff (k + j + unsafeShiftRL m 1) $ mod (u - t) p
            loop (k + m)
            ) 0
    U.unsafeFreeze ff
  where
    !n = U.length f
    !logN = countTrailingZeros n
{-# INLINE ntt #-}

intt :: Int -> Int -> U.Vector Int -> U.Vector Int
intt p g f = U.map ((`rem` p) . (* n')) $ ntt p (recipMod g p) f
  where
    !n' = recipMod (U.length f) p
{-# INLINE intt #-}

convolute :: Int -> Int -> U.Vector Int -> U.Vector Int -> U.Vector Int
convolute p g xs ys
    = U.take l
    . intt p g
    $ U.zipWith (\x y -> x * y `rem` p)
        (ntt p g $ xs U.++ U.replicate (extendToPowerOfTwo l - n) 0)
        (ntt p g $ ys U.++ U.replicate (extendToPowerOfTwo l - m) 0)
  where
    !n = U.length xs
    !m = U.length ys
    !l = n + m - 1

{-# INLINE convolute #-}

extendToPowerOfTwo :: Int -> Int
extendToPowerOfTwo x
    | x > 1 = unsafeShiftRL (-1) (countLeadingZeros (x - 1)) + 1
    | otherwise = 1

growToPowerOfTwo :: U.Vector Int -> U.Vector Int
growToPowerOfTwo v
    | U.null v = U.singleton 0
    | U.length v == 1 = v
    | n <- unsafeShiftRL (-1) (countLeadingZeros (U.length v - 1)) + 1
        = v U.++ U.replicate (n - U.length v) 0


bitReverse :: Int -> Int
bitReverse
    = unsafeCoerce
    . step 32 0xffffffff00000000 0x00000000ffffffff
    . step 16 0xffff0000ffff0000 0x0000ffff0000ffff
    . step 08 0xff00ff00ff00ff00 0x00ff00ff00ff00ff
    . step 04 0xf0f0f0f0f0f0f0f0 0x0f0f0f0f0f0f0f0f
    . step 02 0xcccccccccccccccc 0x3333333333333333
    . step 01 0xaaaaaaaaaaaaaaaa 0x5555555555555555
    . unsafeCoerce
  where
    step :: Int -> Word64 -> Word64 -> Word64 -> Word64
    step i ml mr = \ !x -> unsafeShiftR (x .&. ml) i .|. unsafeShiftL (x .&. mr) i
    {-# INLINE step #-}

powMod :: (Integral a) => a -> Int -> a -> a
powMod x n m
    | n > 0 = go 1 x n
    | n == 0 = 1
    | otherwise = go 1 (recipMod x m) (-n)
  where
    go !acc !y !i
        | i .&. 1 == 0 = go acc (y * y `rem` m) (unsafeShiftR i 1)
        | i == 1 = acc * y `mod` m
        | otherwise = go (acc * y `rem` m) (y * y `rem` m) (unsafeShiftR (i - 1) 1)
{-# INLINE powMod #-}

recipMod :: (Integral a) => a -> a -> a
recipMod x m = go x m 1 0
  where
    go !a !b !u !v
        | b > 0 = case a `quot` b of
            q -> go b (a - (q * b)) v (u - (q * v))
        | otherwise = u `mod` m
{-# INLINE recipMod #-}


-------------------------------------------------------------------------------
-- Utils
-------------------------------------------------------------------------------
rep :: (Monad m) => Int -> (Int -> m ()) -> m ()
rep n = flip MS.mapM_ (stream 0 n)
{-# INLINE rep #-}
rev :: (Monad m) => Int -> (Int -> m ()) -> m ()
rev !n = flip MS.mapM_ (streamR 0 n)
{-# INLINE rev #-}
stream :: (Monad m) => Int -> Int -> MS.Stream m Int
stream !l !r = MS.Stream step l where { step x | x < r = return $ MS.Yield x (x + 1) | otherwise = return MS.Done; {-# INLINE [0] step #-}}
{-# INLINE [1] stream #-}
streamR :: (Monad m) => Int -> Int -> MS.Stream m Int
streamR !l !r = MS.Stream step (r - 1) where { step x | x >= l = return $ MS.Yield x (x - 1) | otherwise = return MS.Done; {-# INLINE [0] step #-}}
{-# INLINE [1] streamR #-}
stream' :: (Monad m) => Int -> Int -> Int -> MS.Stream m Int
stream' !l !r !d = MS.Stream step l where { step x | x < r = return $ MS.Yield x (x + d) | otherwise = return MS.Done; {-# INLINE [0] step #-}}
{-# INLINE [1] stream' #-}
infixl 8 `shiftRL`, `unsafeShiftRL`
shiftRL :: Int -> Int -> Int
shiftRL = unsafeShiftRL
{-# INLINE shiftRL #-}
unsafeShiftRL :: Int -> Int -> Int
unsafeShiftRL (I# x#) (I# i#) = I# (uncheckedIShiftRL# x# i#)
{-# INLINE unsafeShiftRL #-}
type Parser a = StateT C.ByteString Maybe a
runParser :: Parser a -> C.ByteString -> Maybe (a, C.ByteString)
runParser = runStateT
{-# INLINE runParser #-}
int :: Parser Int
int = coerce $ C.readInt . C.dropWhile isSpace
{-# INLINE int #-}
int1 :: Parser Int
int1 = fmap (subtract 1) int
{-# INLINE int1 #-}
char :: Parser Char
char = coerce C.uncons
{-# INLINE char #-}
byte :: Parser Word8
byte = coerce B.uncons
{-# INLINE byte #-}
skipSpaces :: Parser ()
skipSpaces = modify' (C.dropWhile isSpace)
{-# INLINE skipSpaces #-}
lowerBoundM :: (Monad m) => Int -> Int -> (Int -> m Bool) -> m Int
lowerBoundM low high p = go low high where { go !low !high | high <= low = return high | otherwise = p mid >>= bool (go (mid + 1) high) (go low mid) where { mid = low + unsafeShiftRL (high - low) 1}}
{-# INLINE lowerBoundM #-}
upperBoundM :: (Monad m) => Int -> Int -> (Int -> m Bool) -> m Int
upperBoundM low high p = do { flg <- p high; if flg then return high else subtract 1 <$!> lowerBoundM low high (fmap not . p)}
{-# INLINE upperBoundM #-}
lowerBound :: Int -> Int -> (Int -> Bool) -> Int
lowerBound low high p = runIdentity (lowerBoundM low high (return . p))
{-# INLINE lowerBound #-}
upperBound :: Int -> Int -> (Int -> Bool) -> Int
upperBound low high p = runIdentity (upperBoundM low high (return . p))
{-# INLINE upperBound #-}
