main = do
  li <- getLine
  let [a,b,c] = words li
  let ans = compute a b c
  putStrLn (if ans then "YES" else "NO")

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