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 = input().split()
if a[-1]==b[-1] and b[-1]==c[-1]:
    print("YES")
else:
    print("NO")
a,b,c = input().split()
if (a[-1]==b[0]) and (b[-1]==c[0]):
    print("YES")
else:
    print("NO")