import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto abc=readln.split.array;
    if(abc[0][$-1]==abc[1][0] && abc[1][$-1]==abc[2][0])writeln("YES");
    else writeln("NO");
}