open Batteries

let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let s_l = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%s " (fun a -> a)) in
  let c_l_l = List.map (fun s -> String.to_list s |> List.sort compare) s_l in
  
  let intersection xs ys =
    List.fold_left (fun a b -> if List.mem b ys then (b::a) else a) [] xs
  in

  let res = List.fold_left intersection (List.hd c_l_l) (List.tl c_l_l) in

  Printf.printf "%s\n" @@
  String.of_list res

