#include<stdio.h>
#include<string.h>
int main(){
	char a[169], b[169], c[169];
	int la, lb, lc;
	scanf("%s %s %s", &a, &b, &c);
	la = strlen(a);
	lb = strlen(b);
	lc= strlen(c);
	
	if(a[la-1] == b[0] && b[lb-1] == c[0]){
		printf("YES\n");
	}
	
	else{
		printf("NO\n");
	}
	
	return 0;
	
	
}