You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.
A,B,C = map(str,input().split())

flag = True
if A[-1] != B[0]:
    flag = False

if B[-1] == C[0]:
    flag = False

if flag:
    print('YES')
else:
    print('NO')
A,B,C = map(str,input().split())

flag = True
if A[-1] != B[0]:
    flag = False

if B[-1] != C[0]:
    flag = False

if flag:
    print('YES')
else:
    print('NO')