import scala.io.StdIn

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