program main
	implicit none
    character(10) A, B, C
	read(*, *) 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
		write(*, *) 'YES'
	else
		write(*, *) 'NO'
	end if
end program main