import Data.Array.IO
import Control.Monad

main = do
  s <- getLine
  let [n,m] = map (read::String->Int) . words $ s
  v <- newArray (0,n) [0]::IO (IOArray Int [Int])

  forM_ [0..n-1] $ \i -> do
    s <- getLine
    writeArray v i $ map (read::String->Int) . words $ s

  s <- getContents
  let list = map (read::String->Int) $ lines $ s

  forM_ [0..n-1] $ \i -> do
    a <- readArray v i
    putStrLn . show . sum $ zipWith (*) a list