#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue> 
using namespace std;
#define INF 0x3f3f3f3f
char a[15],b[15],c[15];
int main()
{
	while(~scanf("%s%s%s",a,b,c))
	{
		int la=strlen(a);
		int lb=strlen(b);
		int lc=strlen(c);
		if(a[la-1]==b[0]&&b[lb-1]==c[0]) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}