#include<stdio.h>
#include<string.h>
int main()
{
    char A[11]={'\0'};
    char B[11]={'\0'};
    char C[11]={'\0'};
    scanf("%s%s%s",A,B,C);
    if(A[strlen(A)-1]==B[0]&&B[strlen(B)-1]==C[0])printf("YES");
    else printf("NO");
    return 0;
}
