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

  val res = if(a.last == b.head && b.last == c.head) "YES" else "NO"

  println(res)
}