Problem:
 Score : 100 points    Problem Statement 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 1 rng gorilla apple      Sample Output 1 YES  They form a word chain.       Sample Input 2 yakiniku unagi sushi      Sample Output 2 NO  A and B form a word chain, but B and C do not.       Sample Input 3 a a a      Sample Output 3 YES       Sample Input 4 aaaaaaaaab aaaaaaaaaa aaaaaaaaab      Sample Output 4 NO

Solution (Python):
s = input().split()
for i in range(2):
  if s[i][-1] != s[i+1][0]:
    print("NO")
    exit()
print("YES")

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

Solution (Python):
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
data = raw_input().split()

if data[0][-1] == data[1][0] and data[1][-1] == data[2][0]:
    print 'YES'
else:
    print 'NO'

Solution (Python):
A, B, C =  input().split()

print("YES" if A[-1] == B[0] and B[-1] == C[0] else "NO")

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

Solution (Python):
a,b,c=map(str,input().split())

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

Solution (Python):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    ans = "YES"
else:
    ans = "NO"
print(ans)

Solution (Python):
import re;print('YNEOS'[any(x!=y for x,_,y in re.findall('. .',input()))::2])

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

Solution (Python):
A, B, C = [str(i) for i in input().split()]
print("YES" if A[-1] == B[0] and B[-1] == C[0] else "NO")

Solution (Python):
a,b,c=input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

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

Solution (Python):
l=list(input().split())
count=0
if(l[0][-1]==l[1][0]):
  count+=1
if(l[1][-1]==l[2][0]):
  count+=1
if(count==2):
  print('YES')
else:print('NO')

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

Solution (Python):
a, b, c = input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Solution (Python):
A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Solution (Python):
""" AtCoder """

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

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

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

Solution (Python):
print('YES' if (lambda lists=input().split(): True if lists[0][-1] == lists[1][0] and lists[1][-1] == lists[2][0] else False )() else 'NO')

Solution (Python):
a,b,c = input().split()
if (a[-1] == b[0]) and (b[-1] == c[0]):
  print("YES")
else:
  print("NO")

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

Solution (Python):
a,b,c = input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
s=input().split()
if s[0][-1] == s[1][0] and s[1][-1] == s[2][0]:
  print("YES")
else:
  print("NO")

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

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

Solution (Python):
s = input().split()

print('YES' if s[0][-1] == s[1][0] and s[1][-1] == s[2][0] else 'NO')

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

Solution (Python):
a = [x for x in input().split()]

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

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

Solution (Python):
a, b, c = [x for x in input().split()]

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

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

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

Solution (Python):
a,b,c = input().split()
if list(a)[len(a)-1] == list(b)[0] and list(b)[len(b)-1] == list(c)[0]:
    print("YES")
else:
    print("NO")

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

Solution (Python):
A, B, C = [_ for _ in input().split()]

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
A, B, C = input().split()
A = list(A)
B = list(B)
C = list(C)

if A.pop() == B[0] and B.pop() == C[0] :
    print("YES")
else :
    print("NO")

Solution (Python):
A,B,C = [s for s in input().split()]

if (A[-1] == B[0] and B[-1] == C[0]) :
    print("YES")
else :
    print("NO")

Solution (Python):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
str_a, str_b, str_c = input().split()

if str_a[-1] == str_b[0] and str_b[-1] == str_c[0]:
    print("YES")
else:
    print("NO")

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

Solution (Python):
a,b,c=input().split()
print("YES" if a[-1]==b[0] and b[-1]==c[0] else "NO")

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

Solution (Python):
a, b, c = input().split()

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

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

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

Solution (Python):
def abc060_a():
    a, b, c = input().split()
    if a[-1] == b[0] and b[-1] == c[0]:
        print("YES")
    else:
        print("NO")


abc060_a()

Solution (Python):
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")

Solution (Python):
a, b, c = input().split()
if(a[-1:]==b[0] and b[-1:]==c[0]):
    print("YES")
else:
    print("NO")

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

Solution (Python):
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")

Solution (Python):
lines = input().split()
a = lines[0]
b = lines[1]
c = lines[2]
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):



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()

Solution (Python):
a, b, c = input().split()
if ((a[-1] == b[0]) & (b[-1] == c[0])):
  print("YES")
else:
  print("NO")

Solution (Python):
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
a, b, c = input().split()
print("YES" if a[-1]==b[0] and b[-1]==c[0] else "NO")

Solution (Python):
a = [i for i in input().split()]
if a[0][-1] == a[1][0] and  a[1][-1] == a[2][0]:
    print("YES")
else:
    print("NO")

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

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

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

Solution (Python):
a,b,c=map(str,input().split())

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

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

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()

a= []

 

if x[0][len(x[0])-1] == x[1][0] and x[1][len(x[1])-1] == x[2][0]:print("YES")
else:print("NO")

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

Solution (Python):

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

Solution (Python):



def main():
    """Function."""
    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()

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

Solution (Python):
a,b,c = input().split()

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

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

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

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

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

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

Solution (Python):
A,B,C = map(str,input().split())
a = list(A)
b = list(B)
c = list(C)
a_ = len(a)
b_ = len(b)
if a[a_-1] == b[0]:
    if b[b_-1] == c[0]:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

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

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

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

Solution (Python):
line=input().split()
if line[0][-1]==line[1][0] and line[1][-1]==line[2][0]:
    print("YES")
else:
    print("NO")

Solution (Python):
a, b, c = list(input().split())

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

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

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

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

Solution (Python):
A, B, C = map(str, input().split())

if A[-1] == B[0] and B[-1] == C[0]: print('YES')
else: print('NO')

Solution (Python):
A, B, C = input().rstrip().split()
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')

Solution (Python):
a=input().strip().split(" ")

a0=list(a[0])
a1=list(a[1])
a2=list(a[2])

if(a0[-1]==a1[0] and a1[-1]==a2[0]):
    print("YES")
else:
    print("NO")

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

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

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

Solution (Python):
A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Solution (Python):
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
a = input().split(" ")
if a[0][len(a[0])-1] == a[1][0] and a[1][len(a[1])-1] == a[2][0]:
  print("YES")
else:
  print("NO")

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

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

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

Solution (Python):
a,b,c=input().split()
print("YES" if a[-1]==b[0] and b[-1] == c[0] else "NO")

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

Solution (Python):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

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

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

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

Solution (Python):
a, b, c = input().split()

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

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

Solution (Python):
a, b, c = input().split()
if a[len(a) - 1] == b[0] and b[len(b) - 1] == c[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
a , b , c = input().split()

A = a[-1]
B = b[-1]

if A == b[0] and B == c[0]:
	print("YES")
else :
	print("NO")

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

Solution (Python):
a,b,c = input().split()

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

Solution (Python):
a,b,c = map(str, input().split())

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

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

Solution (Python):
a,b,c=input().split()
if (a[len(a)-1]==b[0])&(b[len(b)-1]==c[0]):
    print('YES')
else:
    print('NO')

Solution (Python):
a,b,c=input().split()

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

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

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

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

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

Solution (Python):
A,B,C = map(str, input().split())

if (A[-1] == B[0]) and (B[-1] == C[0]):
    print("YES")
else:
    print("NO")

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

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

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

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

Solution (Python):
a, b, c = input().split(" ")

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

Solution (Python):
a,b,c=input().split();print(['NO','YES'][a[-1]==b[0] and b[-1]==c[0]])

Solution (Python):
a,b,c = list(input().split())
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
a, b, c = input().split()
print(["NO", "YES"][a[-1:] == b[:1] and b[-1:] == c[:1]])

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

Solution (Python):
import numpy as np,math,itertools
a,b,c=map(str,input().split())
if a[::-1][0]==b[0] and b[::-1][0]==c[0]:print("YES")
else:print("NO")

Solution (Python):
a, b, c = map(str, input().split())
listA = list(a)
listB = list(b)
listC = list(c)

if listA[len(listA)-1] == listB[0] and listB[len(listB)-1] == listC[0]:
    print("YES")
else:
    print("NO")

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

Solution (Python):
a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
a, b, c = input().split()
print("YES" if a[-1:] == b[:1] and b[-1:] == c[:1] else "NO")

Solution (Python):
a, b, c = input().split()
print("YES" if a.endswith(b[:1]) and b.endswith(c[:1]) else "NO")

Solution (Python):

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

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

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

Solution (Python):
a,b,c = map(str, input().split())
list_a = list(a)
list_b = list(b)
list_c = list(c)
if list_a[-1] == list_b[0] and list_b[-1] == list_c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
a, b, c = map(str, input().split())

al = len(a)
bl = len(b)

if a[al - 1] == b[0] and b[bl - 1] == c[0]:
    print("YES")

else:
    print("NO")

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

Solution (Python):
a, b, c = input().split()
if a[-1:] == b[:1] and b[-1:] == c[:1]:
  print("YES")
else:
  print("NO")

Solution (Python):
s = input().split()
a, b, c = s[0], s[1], s[2]
if b.startswith(a[-1:]) and c.startswith(b[-1:]):
  print("YES")
else:
  print("NO")

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

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

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

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

Solution (Python):
a = list(map(str,input().split()))
for i in range(2):
  if not a[i][-1] == a[i+1][0]:
    print("NO")
    exit()
else:
  print("YES")

Solution (Python):
S=list(input().split())
ans='YES'
for i in range(len(S)-1):
    if S[i][-1]!=S[i+1][0]:
        ans='NO'
print(ans)

Solution (Python):
a, b, c = input().split()

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

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


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


main()

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

Solution (Python):
a,b,c = input().split()

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

Solution (Python):


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

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

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

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

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

Solution (Python):
A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
  print("YES")
else:
  print("NO")

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

Solution (Python):
x,y,z=input().split()


if x[-1]==y[0] and y[-1]==z[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
A,B,C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Solution (Python):
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")

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

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

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

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

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

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

Solution (Python):
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:print("NO")

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

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

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

Solution (Python):


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

if __name__ == '__main__':
    main()

Solution (Python):
a,b,c = map(str,input().split())
print(["NO","YES"][a[-1]==b[0] and b[-1]==c[0]])

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

Solution (Python):
a, b, c = input().split()

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

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

Solution (Python):

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

Solution (Python):
A, B, C = [s for s in input().split()]
ans = "NO"

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

print(ans)

Solution (Python):
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")

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

Solution (Python):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):


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

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

if __name__ == '__main__':
    main()

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

Solution (Python):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
a, b, c = input().split()

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

Solution (Python):
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

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

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

Solution (Python):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
a, b, c = map(list, input().split())
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")

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

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

Solution (Python):
a,b,c = input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

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

Solution (Python):
A,B,C=(i for i in input().split())
if A[-1]==B[0] and B[-1]==C[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
A, B, C = (i for i in input().split())

a = A[-1]
b = B[0]
bb = B[-1]
c = C[0]

if a == b and bb == c:
    print("YES")
else:
    print("NO")

Solution (Python):
A, B, C = (i for i in input().split())

a = A[len(A)-1]
b = B[0]
bb = B[len(B)-1]
c = C[0]

if a == b and bb == c:
    print("YES")
else:
    print("NO")

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

Solution (Python):
a,b,c = map(str,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")

Solution (Python):
l = raw_input().split()
print "YES" if l[0][-1] == l[1][0] and l[1][-1] == l[2][0] else "NO"

Solution (Python):
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()

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

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

Solution (Python):
a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")

Solution (Python):


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

Solution (Python):
a, b, c = input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

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

Solution (Python):
a,b,c = input().split()
A = list(str(a))
B = list(str(b))
C = list(str(c))

if((A[len(A)-1] == B[0]) and (B[len(B)-1] == C[0])):
	print("YES")
else:
	print("NO")

Solution (Python):


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

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

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

Solution (Python):

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

if A[len(A) - 1] == B[0] and B[len(B) - 1] == C[0]:
    print('YES')
else:
    print('NO')

Solution (Python):
a,b,c = input().split()

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

Solution (Python):
A, B, C = input().split()

print("YES" if (A[-1] == B[0] and B[-1] == C[0]) else "NO")

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

Solution (Python):
[a,b,c]=[i for i in input().split()]
if a[len(a)-1]==b[0] and b[len(b)-1]==c[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
a,b,c = raw_input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print 'YES'
else:
  print 'NO'

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

Solution (Python):
a,b,c=input().split();print(("NO","YES")[a[-1]==b[0]and b[-1]==c[0]])

Solution (Python):
a,b,c=input().split();print(("NO","YES")[a[-1]==b[0]and b[-1]==c[0]])

Solution (Python):
A,B,C=map(str,input().split())

if A[-1]==B[0] and B[-1]==C[0]:
  print("YES")
else:
  print("NO")