open Batteries
let () =
  let a,b,c = Scanf.scanf "%s %s %s " (fun a b c -> a,b,c) in

  Printf.printf "%s\n" @@
  if 
    (String.sub a (String.length a - 1) 1) = (String.sub b 0 1) &&
    (String.sub b (String.length b - 1) 1) = (String.sub c 0 1)
  then "YES" else "NO"
