import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val words = sc.nextLine().split(" ")

    if (words(0).last == words(1).head && words(1).last == words(2).head) {
      println("YES")
    } else {
      println("NO")
    }
  }
}