module Main where
--import Debug.Trace
import Data.List
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: Int -> Int -> [[Int]] -> [Int] -> [Int]
solve n m aij bj = iterR 0 where
    iterR i
        | i >= n = []
        | otherwise = iterC 0 bj : iterR (i+1) where
            iterC _ [] = 0
            iterC j (b:bs)
                | otherwise = b * mt ! (i, j) + iterC (j+1) bs
    mt = listArray ((0,0), (n-1,m-1)) (concat aij)

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Int]]
readLines 0 = return []
readLines n = readLine >>= (\a -> fmap (a:) (readLines (pred n)))
            
main :: IO() 
main = do
    [n, m] <- readLine
    aij <- readLines n
    bj  <- readLines m
    mapM_ print (solve n m aij (concat bj))

