(defn grid [h]
  (let [white? (fn [s] (re-find #"^\.+$" s))
        grid (for [_ (range h)] (read-line))
        not-whites (remove white? grid)
        result (->> (apply map (cons (fn [& args]
                                       (let [s (apply str args)]
                                         (if (white? s)
                                           nil
                                           s)))
                                     not-whites))
                    (remove nil?)
                    (apply map (fn [& args] (apply str args))))]
    (doseq [s result] (println s))))

(grid (Integer/parseInt (first (clojure.string/split (read-line) #"\s"))))