let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = Array.init h @@ fun _ -> Array.init w @@ fun _ -> Scanf.scanf " %c" @@ fun c -> c
let is_ok = ref false
let bss = Array.make_matrix h w 0
let _ =
  for i = 0 to h - 1 do
    is_ok := false;
    for j = 0 to w - 1 do if css.(i).(j) = '#' then is_ok := true done;
    if !is_ok then for j = 0 to w - 1 do bss.(i).(j) <- bss.(i).(j) + 1 done done;
  for j = 0 to w - 1 do
    is_ok := false;
    for i = 0 to h - 1 do if css.(i).(j) = '#' then is_ok := true done;
    if !is_ok then for i = 0 to h - 1 do bss.(i).(j) <- bss.(i).(j) + 1 done done;
  for i = 0 to h - 1 do
    is_ok := false;
    for j = 0 to w - 1 do if bss.(i).(j) = 2 then (is_ok := true; print_char css.(i).(j)) done;
    if !is_ok then print_newline () done