module Main (main) where


main :: IO ()
main = do
    strs <- words <$> getLine
    let a = strs !! 0
    let b = strs !! 1
    let c = strs !! 2
    if last a == head b && last b == head c
        then putStrLn "YES"
        else putStrLn "NO"
