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

int main()
{
    char a[11],b[11],c[11];
    int a1,b1,c1;
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    a1=strlen(a)-1;
    b1=strlen(b)-1;
    c1=strlen(c)-1;
    if(a[a1]==b[0] && b[b1]==c[0])
        printf("YES");
    else
        printf("NO");

    return 0;

}
