A, B, C = input().split()

if(A[-1] == B[0] and B[-1] == C[0]):

  print('YES')

else:

  print('NO')
A, B, C = input().split()

ans = "NO"

if A[-1] == B[0] and B[-1] == C[0]:

  ans = "YES"

print(ans)
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

A, B, C = input().split()
ans = "NO"
if A[-1] == B[0] and B[-1] == C[0]:
    ans = "YES"
print(ans)

+ans = "NO" -    print("YES") -else: -    print("NO") +    ans = "YES" +print(ans)