open Batteries
module Mymap = Map.Make(Int)
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let m = Scanf.scanf "%d " (fun a -> a) in
  let pair_lst = Array.to_list @@ Array.init m (fun _ -> Scanf.scanf "%d %d " (fun a b -> a,b)) in

  let amap = List.fold_left (fun accum (x,y) -> 
      Mymap.modify_opt x (fun v_opt -> match v_opt with
            Some v -> Some (v + 1)
          | None -> Some 1
        ) accum |>
      Mymap.modify_opt y (fun v_opt -> match v_opt with
            Some v -> Some (v + 1)
          | None -> Some 1
        ) 
    ) (Mymap.empty) pair_lst
  in

  let pair_lst = Mymap.bindings amap in
  let pair_lst = List.sort compare pair_lst in
  List.iter (fun (x,y) -> Printf.printf "%d\n" y) pair_lst
