(defn input []
  (let [[N M] (->> (clojure.string/split (read-line) #"\s")
                (map #(Integer/parseInt %)))]
    (list N M
      (->> (repeatedly M read-line)
        (into []
          (comp (mapcat #(clojure.string/split % #"\s"))
            (map #(Integer/parseInt %))))))))

(defn CoutningRoads [[N M Rs]]
  (->> (sort Rs)
    frequencies
    (transduce
      (comp (map second)
        (map #(format "%d\n" %)))
      str)))

(->> (input)
  CoutningRoads
  println)