open Array
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = init h @@ fun _ -> init w @@ fun _ -> Scanf.scanf " %c" @@ fun c -> c
let rows = let rec f i =
  if i >= h then []
  else if to_list css.(i) |> List.for_all ((=) '.') then f @@ i + 1
  else i :: f (i + 1) in f 0 |> of_list
let cols = let rec f i =
  if i >= w then []
  else
    let is_space = ref true in
    for j = 0 to h - 1 do if css.(j).(i) <> '.' then is_space := false done;
    if !is_space then f (i + 1) else i :: f (i + 1) in f 0 |> of_list
let ans = make_matrix (h - length rows) (w - length cols) ' '
let _ =
  for i = 0 to length rows - 1 do
    for j = 0 to length cols - 1 do print_char css.(rows.(i)).(cols.(j)) done;
    print_newline () done