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 is_shiritori(s):
    before_mozi = None
    for mozi in s.split():
        if before_mozi is None:
            before_mozi = mozi
            continue
        else:
            if mozi[0] is not before_mozi[-1]:
                print("No")
                return False
            before_mozi = mozi
    print("OK")

is_shiritori(input())

def is_shiritori(s):
    before_mozi = None
    for mozi in s.split():
        if before_mozi is None:
            before_mozi = mozi
            continue
        else:
            if mozi[0] is not before_mozi[-1]:
                print("NO")
                return False
            before_mozi = mozi
    print("YES")

ss = input()
is_shiritori(ss)