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 true in
  let col = Array.make w true in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if ass.(i).[j] = '#' then begin
        row.(i) <- false;
        col.(j) <- false
      end
    done
  done;
  for i = 0 to h - 1 do
    if not row.(i) then begin
      for j = 0 to w - 1 do
        if not col.(j) then
          print_char ass.(i).[j]
      done;
      print_newline ()
    end
  done
