type Vector=[Int]

product :: (Int,Int)->Int
product (x,y) = x*y

vproduct :: Vector->Vector->Int
vproduct a b = sum $ zipWith (*) a b

toVector :: [String] -> Vector
toVector = map (read :: String->Int)

myDivide :: Int->([a],[a])->([a],[a])
myDivide 0 (x,y) = (x,y)
myDivide n (x,y) = myDivide (n-1) (x++[head y],tail y)

mproduct :: Vector->[Vector]->Vector
mproduct v = map $ vproduct v

dim :: String->Int
dim=(read::String->Int).head.words.head.lines

prepare :: String->([Vector],Vector)
prepare xs = (\(x,y)->(map (toVector.words) x,toVector y)) $ myDivide (dim xs) ([],tail.lines $ xs)

calc :: ([Vector],Vector)->Vector
calc (a,b) = mproduct b a

printv :: Vector->IO ()
printv = mapM_ print

main=getContents >>= printv.calc.prepare