type info = {b : int;
             f : int;
             r : int;
             v : int} ;;
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d %d %d %d\n" (fun x y z w -> {b = x; f = y; r = z; v = w})) in
  for i = 1 to 4 do             (* 棟 *)
    for j = 1 to 3 do           (* 階 *)
      for k = 1 to 10 do         (* 番号 *)
        let f res =
          for m = 0 to (n-1) do
            if (as_.(m)).b = i && (as_.(m)).f = j && (as_.(m)).r = k then
              begin res := !res + (as_.(m)).v end
          done;
          if !res <> 0 then begin  Printf.printf " %d" !res end
          else Printf.printf " %d" 0
        in
        f (ref 0)
      done ;
      print_newline ()
    done;
    if i < 4 then begin print_endline "####################" end
  done;;

