import Control.Monad
import Data.List

toThree :: String -> IO [Int]
toThree l =  return (map read . words $ l)

toArray :: [String] -> [[Int]]
toArray = map (map read . words)

getNLine :: [Int] -> IO ([[Int]], [[Int]])
getNLine (n:m:l:_) = do
        a <- replicateM n getLine
        b <- replicateM m getLine
        return (toArray a, toArray b)

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

solv :: ([[Int]], [[Int]]) -> IO [[Int]]
solv (a, _b) = return $ map (\al -> map (\bl -> multi al bl ) b ) a
    where
      b = transpose _b

showRes :: [[Int]] -> String
showRes [] = ""
showRes (x:xs) = (concat . intersperse " " . map show $ x) ++ "\n" ++ (showRes xs)

main = getLine >>= toThree >>= getNLine >>= solv >>= putStr . showRes