solver::(String,String,String)->String
solver (a,b,c) = if (last a == head b)&&(last b == head c) then "YES" else "NO"

main::IO()
main =do
  abcc<-getLine
  let a:b:c:[]=words abcc
  putStr (solver (a,b,c))
  putStr "\n"
