character a*10, b*10, c*10
integer lena, lenb
read*, a, b, c
lena=len_trim(a)
lenb=len_trim(b)
if(a(lena:lena) == b(1:1) .and. b(lenb:lenb) == c(1:1)) then
	print*, 'YES'
else 
	print*,'NO'
end if
end