function Main(input) {
	input = input.trim().split(" ");
  var list1 = input[0].split("");
  var list2 = input[1].split("");
  var list3 = input[2].split("");
  if(list1[list1.length - 1] == list2[0] && list2[list1.length - 1] == list3[0]){
     console.log("YES");
     }else{
     console.log("NO");
     }
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
