# -*- coding: utf-8 -*-


def main():
    a, b, c = map(str, input().split())

    if a[-1] == b[0] and b[-1] == c[0]:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-


def main():
    a, b, c = map(str, input().split())

    if a[-1] == b[0] and b[-1] == c[0]:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-