import scala.io.StdIn._

object Main{
    def main(args:Array[String]){
        val s = readLine.split(" ")
        if (s(0).last == s(1).head && s(1).last == s(2).head) {
            printf("YES\n")
        } else {
            printf("NO\n")
        }
    }
}