import Data.Functor( (<$>))
import Data.Map.Strict( fromListWith, findWithDefault)
import Data.List( unfoldr, intercalate)
import Control.Monad( replicateM)


main = do
    n <- read <$> getLine
    infos <- replicateM n $ (read <$>) . words <$> getLine
    let
	mp = fromListWith (+) $	t <$> infos
	  where
	    t [b,f,r,v] = ((b,f,r),v)

	queries = [(b,f,r) | b<-[1..4], f<-[1..3], r<-[1..10]]

	ansRawData::[Int]
	ansRawData = (\r-> findWithDefault 0 r mp) <$> queries

	sausage size list = unfoldr pack list
	  where
	    pack [] = Nothing
	    pack minced_meat = Just $ splitAt size minced_meat

	buildings = sausage 3 $
			((' ':) . unwords . (show <$>)) <$>
							    sausage 10 ansRawData

    putStrLn `mapM_` intercalate [replicate 20 '#'] buildings

