function main(s) {
	s = s.split("\n")[0].split(" ");
	console.log(((s[0][s[0].length-1] === s[1][0]) && (s[1][s[1].length-1] === s[2][0])) ? "YES" : "NO");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

