import Control.Applicative
import Control.Monad

main = do
    n <- readLn
    ss <- replicateM n ( map read.words <$> getLine ) ::IO [[Int]]
    let resid = concat[concat[" "++unwords[ show(sum [ v| (b:f:r:v:_) <- ss, (b,f,r) == (x,y,z)]) | z <- [1..10]] ++ "\n"| y <- [1..3]]++"####################\n"| x <- [1..4]]
    putStr $ take (length resid - 21) resid