program ABC060A
    implicit none
    character(10)::A,B,C
    read(5,*)A,B,C

    if(A(len_trim(A):len_trim(A))==B(1:1).and.B(len_trim(B):len_trim(B))==C(1:1))then
        print'(A)',"YES"
    else
        print'(A)',"NO"
    end if
end program ABC060A