(defn input [[H _]]
  (if (zero? H)
    '()
    (cons (apply list (read-line))
      (input (list(dec H))))))


(defn getHW []
  (->> (clojure.string/split (read-line) #"\s") (map #(Integer/parseInt %))))

(defn GridCompression [A]
  (->> A
    (remove (fn [x](every? #(= \. %) x)))
    (apply map list)
    (remove (fn [x](every? #(= \. %) x)))
    (apply map str)
    (map #(format "%s\n" %))
    (apply str)))


(println (GridCompression (input (getHW))))