import std.stdio, std.conv, std.string, std.math;

void main(){
	auto ip = readln.split.to!(string[]);
	auto A = ip[0];
	auto B = ip[1];
	auto C = ip[2];
	if(A[$-1] == B[0] && B[$-1] == C[0]) "YES".writeln;
	else "NO".writeln;
}