
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val a, b, c = sc.next()

  if (a.charAt(a.length - 1) == b.charAt(0) && b.charAt(b.length - 1) == c.charAt(0)) {
    println("YES")
  } else {
    println("NO")
  }
}
