import Data.List

toListI = map read . words
addSum x = x ++ [sum x]
printMatrix = mapM_ putStrLn . map (unwords . map show)

main = getContents >>= printMatrix . transpose . map addSum . transpose . map (addSum . toListI) . tail . lines