import Control.Applicative

main :: IO ()
main = do
  strs <- words <$> getLine
  case strs of [x, y, z] -> if last x == head y && last y == head z then putStrLn "YES"
                                                                    else putStrLn "NO"
               _ -> putStrLn "NO"