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 by, bx = make h false, make w false
let _ =
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do if css.(i).[j] = '#' then (by.(i) <- true; bx.(j) <- true) done done;
  for i = 0 to h - 1 do
    let is_ok = ref false in
    for j = 0 to w - 1 do if by.(i) && bx.(j) then (is_ok := true; print_char css.(i).[j]) done;
    if !is_ok then print_newline () done