object bc0601 extends App {
	val line = scala.io.StdIn.readLine
	val a = line.split(" ")(0).toList
	val b = line.split(" ")(1).toList
	val c = line.split(" ")(2).toList

	if(a(a.size - 1) == b(0)){
		if(b(b.size - 1) == c(0)){
			println("YES");
		}else{
			println("NO")
		}
	}else{
		println("NO")
	}
}