type Matrix1 = [Int]
type Matrix2 = [Matrix1]

multiply :: Matrix2 -> Matrix1 -> Matrix1
multiply [] b = []
multiply (a:as) b = (calc a b):(multiply as b)
    where
        calc a b = sum $ map (\(a,b) -> a*b) $ zip a b

printMatrix :: Matrix1 -> IO ()
printMatrix = putStr.unlines.(map show)

addTail :: [a] -> a -> [a]
addTail a b = a ++ [b]

readA :: Int -> Int -> Matrix2 -> IO Matrix2
readA 0 _ a = return a
readA n m a = getLine >>= return.(map $ \n -> read n :: Int).words >>= (readA (n-1) m).(addTail a)

readB :: Int -> Matrix1 -> IO Matrix1
readB 0 b = return b
readB m b = getLine >>= return.(\n -> read n :: Int) >>= (readB (m-1)).(addTail b)

main :: IO ()
main = do
    [n, m] <- getLine >>= return.(map $ \n -> read n :: Int).words
    a <- readA n m []
    b <- readB m []
    printMatrix $ multiply a b

