open String
let () = Scanf.scanf "%s %s %s\n"
	(fun a b c ->
    let alen = length a in
    let blen = length b in
    let al = a.[alen-1] in
    let bf = b.[0] in
    let bl = b.[blen-1] in
    let cf = c.[0] in
    Printf.printf "%s\n" (if al = bf && bl = cf then "YES" else "NO"))