import Control.Applicative

main :: IO ()
main = do
    [a,b,c] <- words <$> getLine
    putStrLn $　solve a b c
    
solve :: String -> String -> String -> String
solve a b c = if last a == head b && last b == head a then "YES" else "NO"