import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val A = sc.next()
  val B = sc.next()
  val C = sc.next()

  println(if (A.last == B.head && B.last == C.head) "YES" else "NO")
}