program main
    use,intrinsic :: iso_fortran_env
    implicit none
    character(10):: a,b,c
    integer(int32):: la,lb,lc

    read*, a,b,c
    la = len_trim(a)
    lb = len_trim(b)
    lc = len_trim(c)

    if (a(la:la) == b(1:1) .and. b(lb:lb) == c(1:1)) then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    end if
    
end program main