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


int main()
{
    char first[15],second[15],third[15];
    scanf("%s%s%s",first,second,third);
    int len=strlen(first);
    if(first[len-1]==second[0])
    {
        len=strlen(second);
        if(second[len-1]==third[0]){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}
