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