[<EntryPoint>]
let main argv =
    //printfn "Make it!" 
    let abc = System.Console.ReadLine().Split()
    let a = abc.[0]
    let b = abc.[1]
    let c = abc.[2]
    let ans = if a.[a.Length-1] = b.[0] && b.[b.Length-1] = c.[0] then "YES" else "NO"
    printfn "%s" ans
    0