let a,b,c = Scanf.scanf "%s %s %s" (fun a b c -> a,b,c)
in
    if (a.[String.length a - 1] = b.[0] && b.[String.length b - 1] = c.[0]) 
    then 
        Printf.printf "YES\n"
    else
        Printf.printf "NO\n";;