function Main(input) {
	input = input.split(" ");
        var len1=input[0].length, len2=input[1].length;
	if(input[0][len1-1] == input[1][0] && input[1][len2-1] == input[2][0])
          console.log('YES');
        else
          console.log('NO');
}

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