object Main {
	val s = new java.util.Scanner(System.in)
	def main(args: Array[String]) {
		val a, b, c = s.next();
		println(if(shiritori(a,b)&&shiritori(b, c))
			"YES"else"NO");
	}
	def shiritori(a1:String,a2:String):Boolean={
		a1.charAt(a1.length()-1)==a2.charAt(0);
	}
}
