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`.
def shiritori(A: str, B: str, C: str) -> bool:
    return A[-1] == B[0] and B[-1] == C[0]


if __name__ == "__main__":
    A, B, C = input().split()
    yes = shiritori(A, B, C)
    print('Yes' if yes else 'No')

def shiritori(A: str, B: str, C: str) -> bool:
    return A[-1] == B[0] and B[-1] == C[0]


if __name__ == "__main__":
    A, B, C = input().split()
    yes = shiritori(A, B, C)
    print('YES' if yes else 'NO')
