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