let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let () =
  let max_b = 4 in
  let max_f = 3 in
  let max_r = 10 in
  let ary = Array.make_matrix max_b (max_f * max_r) 0 in
  let n = read_int () in
  for _ = 1 to n do
    let l = read_line () in
    match List.map int_of_string (split l ' ') with
    | [] | [_] | _::_::[] | _::_::_::[] -> exit 1
    | b :: f :: r :: v :: _ -> ary.(b - 1).(max_r * (f - 1) + r - 1) <- v
  done;
  for i = 1 to max_b do
    for j = 1 to (max_f * max_r) do
      if j mod max_r = 0 then Printf.printf " %d\n" ary.(i - 1).(j - 1)
      else Printf.printf " %d" ary.(i - 1).(j - 1)
    done;
    if i <> max_b then Printf.printf "####################\n"
  done