import scala.io.StdIn

object Main extends App {
  StdIn.readLine().split(" ") match {
    case Array(a, b, c)
      if (a.last == b.head &&
          b.last == c.head ) => println("YES")
    case _ => println("NO")
  }
}