let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ass = Array.init h @@ fun _ ->
    Scanf.scanf "%s\n" @@ fun as_ -> as_ in
  let row = Array.make h false in
  let col = Array.make w false in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if ass.(i).[j] = '#' then begin
        row.(i) <- true;
        col.(j) <- true
      end
    done
  done;
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if row.(i) || col.(j) then
        print_char ass.(i).[j]
    done;
    print_newline ()
  done
