#include<stdio.h>
#include<string.h>

int main()

{
	char a[1000], b[1000], c[1000];
	scanf("%s%s%s", a, b, c);
	int l1 = strlen(a);
	int l2 = strlen(b);
	if(a[l1-1] == b[0] && b[l2-1] == c[0])
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
		
	}
	return 0;
}

