import Control.Applicative
import Control.Monad

main = do
    n <- fmap (read :: String -> Int) . words <$> getLine
    let a = n !! 0
        b = n !! 1
    as <- getAs a
    bs <- getBs b
    let anses = foldr (calc bs) [] as
    mapM_ (\x -> putStrLn $ show x) anses

getAs :: Int -> IO [[Int]]
getAs n = do
    forM [1..n] $ \_ -> do
        fmap (read :: String -> Int) . words <$> getLine

getBs :: Int -> IO [Int]
getBs n = do
    forM [1..n] $ \_ -> do
        readLn :: IO Int

calc :: [Int] -> [Int] -> [Int] -> [Int]
calc _ [] acc = acc
calc bs as acc = (mul bs as) : acc

mul :: [Int] -> [Int] -> Int
mul [] [] = 0
mul (b:bs) (a:as) = (a * b) + mul bs as