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.

-----Constraints-----
 - A, B and C are all composed of lowercase English letters (a - z).
 - 1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.

-----Input-----
Input is given from Standard Input in the following format:
A B C

-----Output-----
Print YES or NO.

-----Sample Input-----
rng gorilla apple

-----Sample Output-----
YES

They form a word chain.

Difficulty: EASY

Solutions:
(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()
if a[-1] == b[0] and b[-1] == c[0]:
	print('YES')
else:
	print('NO')


(a, b, c) = map(str, input().split())
r = 'NO'
if a[-1] == b[0] and b[-1] == c[0]:
	r = 'YES'
print(r)


(x, y, z) = input().split()
print('YES' if x[-1] == y[0] and y[-1] == z[0] else 'NO')


(A, B, C) = list(map(str, input().split()))
if A[-1] == B[0] and B[-1] == C[0]:
	print('YES')
else:
	print('NO')


(a, b, c) = input().split()
len_a = len(a)
len_b = len(b)
if a[len_a - 1] == b[0] and b[len_b - 1] == c[0]:
	print('YES')
else:
	print('NO')


A = list(input().split())
print('YES' if A[0][-1] == A[1][0] and A[1][-1] == A[2][0] else 'NO')


(A, B, C) = input().split()
print('YNEOS'[A[-1] != B[0] or B[-1] != C[0]::2])


(a, b, c) = input().split()
print('YNEOS'[a[::-1][0] != b[0] or b[::-1][0] != c[0]::2])


(a, b, c) = map(list, input().split())
print('YNEOS'[a[-1] != b[0] or b[-1] != c[0]::2])


(A, B, C) = input().split()
print(['NO', 'YES'][A[-1] == B[0] and B[-1] == C[0]])


(a, b, c) = list(map(str, input().split()))
result = 'ret'
if a[-1] == b[0] and b[-1] == c[0]:
	result = 'YES'
else:
	result = 'NO'
print(result)


import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

def lstr():
	return input().split()

def lint():
	return list(map(int, input().split()))

def lintdec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [int(input()) for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]
(A, B, C) = lstr()
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')


l = input().split()
if l[0][-1] == l[1][0] and l[1][-1] == l[2][0]:
	print('YES')
else:
	print('NO')


a = list(str(input()).split())
print('YES' if a[0][-1] == a[1][0] and a[1][-1] == a[2][0] else 'NO')


(a, b, c) = map(str, input().split())
if a[len(a) - 1] == b[0] and b[len(b) - 1] == c[0]:
	print('YES')
else:
	print('NO')


(a, b, c) = input().split()
print(' YNEOS'[a[-1] == b[0] and b[-1] == c[0]::2])


s = list(input().split())
if s[0][-1] == s[1][0] and s[1][-1] == s[2][0]:
	ans = 'YES'
else:
	ans = 'NO'
print(ans)


(A, B, C) = map(str, input().split())
print('YNEOS'[not (A[-1] == B[0] and B[-1] == C[0])::2])


S = input().split()
print('YES' if S[0][-1] == S[1][0] and S[1][-1] == S[2][0] else 'NO')


(s1, s2, s3) = input().split()
print('YES') if s1[-1] == s2[0] and s2[-1] == s3[0] else print('NO')


def atc_060a(input_value: str) -> str:
	(A, B, C) = map(str, input_value.split(' '))
	if A[-1] == B[0] and B[-1] == C[0]:
		return 'YES'
	else:
		return 'NO'
input_value = input()
print(atc_060a(input_value))


(A, B, C) = map(list, input().split())
print(['NO', 'YES'][A[-1] == B[0] and B[-1] == C[0]])


(a, b, c) = [x for x in input().split()]
print('YES' if a[-1:] == b[0] and b[-1:] == c[0] else 'NO')


print((lambda x: 'YES' if x[0][-1] == x[1][0] and x[1][-1] == x[2][0] else 'NO')(input().split()))


(A, B, C) = [_ for _ in input().split()]
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')


arr = input().split()
print('YES' if arr[0][-1] == arr[1][0] and arr[1][-1] == arr[2][0] else 'NO')


(A, B, C) = map(str, input().split())
print('YNEOS'[A[-1] != B[0] or B[-1] != C[0]::2])


(a, b, c) = input().split()
print('NYOE S'[a[-1] + b[-1] == b[0] + c[0]::2])


(a, b, c) = input().split()
n = len(a)
m = len(b)
if a[n - 1] == b[0] and b[m - 1] == c[0]:
	print('YES')
else:
	print('NO')


(a, b, c) = input().split()
A = list(a)
B = list(b)
C = list(c)
if A[len(A) - 1] == B[0] and B[len(B) - 1] == C[0]:
	print('YES')
else:
	print('NO')


(a, b, c) = input().split()
print('YES' * (a[-1] == b[0]) * (b[-1] == c[0]) or 'NO')


s = input().split()
t = len(s)
cnt = 0
for i in range(t):
	if i != t - 1:
		if s[i][-1] == s[i + 1][0]:
			cnt += 1
	else:
		break
if cnt == t - 1:
	print('YES')
else:
	print('NO')


s = input().split()
print('YNEOS'[s[0][-1] != s[1][0] or s[1][-1] != s[2][0]::2])


(X, Y, Z) = input().split()
if X[-1] == Y[0] and Y[-1] == Z[0]:
	print('YES')
else:
	print('NO')


s = input().split()
print('YES' if all((s[i][-1] == s[i + 1][0] for i in range(len(s) - 1))) else 'NO')


w = input().split()
if w[0][-1] == w[1][0] and w[1][-1] == w[2][0]:
	print('YES')
else:
	print('NO')


(a, b, c) = input().split()
ans = 'NO'
if a[-1] == b[0]:
	if b[-1] == c[0]:
		ans = 'YES'
print(ans)


n = input().split()
print('YES' if n[0][-1] == n[1][0] and n[1][-1] == n[2][0] else 'NO')


(a, s, d) = input().split()
print('YES') if a[-1] == s[0] and s[-1] == d[0] else print('NO')


(A, B, C) = map(str, input().split())
A_num = len(A)
B_num = len(B)
if A[A_num - 1] == B[0] and B[B_num - 1] == C[0]:
	print('YES')
else:
	print('NO')


(A, B, C) = input().split()
print(['YES', 'NO'][A[-1] != B[0] or B[-1] != C[0]])


def resolve():
	(a, b, c) = input().split()
	print('YES' if a[-1] == b[0] and b[-1] == c[0] else 'NO')

def __starting_point():
	resolve()
__starting_point()


(sa, sb, sc) = input().split()
print('YES' if sa[-1] == sb[0] and sb[-1] == sc[0] else 'NO')