open Array
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let is_ok = ref false
let rows, cols = make h false, make w false
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 rows.(i) <- true 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 cols.(j) <- true done;
  for i = 0 to h - 1 do
    is_ok := false;
    for j = 0 to w - 1 do if rows.(i) && cols.(j) then (is_ok := true; print_char css.(i).[j]) done;
    if !is_ok then print_newline () done