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

shiritori :: String -> String -> String -> Bool
shiritori a b c = (last a == head b) && (last b == head c)