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):
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]:
  if b[-1] == c[0]:
    print('YES')
  else:
    print('NO')
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[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 list(A)[-1] == list(B)[0] and list(B)[-1] == list(C)[0] 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):
lines = input().split()
last_a = lines[0][len(lines[0])-1]
first_b = lines[1][0]
last_b = lines[1][len(lines[1])-1]
first_c = lines[2][0]

if last_a == first_b and last_b == first_c:
    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[-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):
n = input().split()
print('YES' if n[0][-1] == n[1][0] and n[1][-1] == n[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 = 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 = 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[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]:
    print('YES')
else:
    print('NO')

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


if __name__ == "__main__":
    test()

Solution (Python):
a,b,c=input().split()
print("YES" if a[-1]==b[0] and b[-1]==c[0] else "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 = 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=list(input().split())
if a[0][-1] == a[1][0] and a[1][-1] == a[2][0]:
    print("YES")
else:
    print("NO")

Solution (Python):
word1,word2,word3 = map(str,input().split())
if word1[-1] == word2[0] and word2[-1] == word3[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):
Tmp = []
Tmp = input().rstrip().split(' ')

S1 = Tmp[0]
S2 = Tmp[1]
S3 = Tmp[2]

if S1[-1]==S2[0] and S2[-1]==S3[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())
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):
def main():
    s = input().split()
    
    s1=list(s[0])
    s2=list(s[1])
    s3=list(s[2])
    a=len(s1)
    b=len(s2)
    c=len(s3)
    if(s1[a-1]==s2[0] and s2[b-1]==s3[0]):
        print("YES")
    else:
        print("NO")
    
main()

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 sys
INF = float("inf")


def yes():
    print("YES")  


def no():
    print("NO")  


def solve(A: str, B: str, C: str):
    if A[-1] == B[0] and B[-1] == C[0]:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = next(tokens)  
    B = next(tokens)  
    C = next(tokens)  
    solve(A, B, C)


if __name__ == '__main__':
    main()

Solution (Python):
A,B,C = 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()
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("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=[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()
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('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 = 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):
s = input().split()

a = s[0]
b = s[1]
c = s[2]
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(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 = input().split()
x = int(a[-1]==b[0]) * int(b[-1]==c[0])
if x == 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 = 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(' ')
print('YES' if a[-1] == b[0] and b[-1] == c[0] else 'NO')

Solution (Python):
s = list(map(str,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()

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]+c[0]!=b[0]+b[-1]::2])

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] 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().rstrip().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 = 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("YNEOS"[a[-1]!=b[0]or b[-1]!=c[0]::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()
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 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 = list(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[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()
print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')

Solution (Python):
A,B,C=[x for x 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):
a,b,c = input().split()

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

Solution (Python):
num = input().split()
print('YES') if num[0][-1]==num[1][0] and num[1][-1]==num[2][0] 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):
s=input().split()
if s[0][-1]==s[1][0] and s[1][-1]==s[2][0]:
    print("YES")
else:
    print("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 = 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 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()
    print('YNEOS'[A[-1] != B[0] or B[-1] != C[0]::2])


main()

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 = [elem for elem in 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 = 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):
words = input().split()
if words[0][-1] == words[1][0] and words[1][-1] == words[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 = 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):
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]) & (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()
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 = 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):
s = list(input().split())
if s[0][-1] == s[1][0] and s[1][-1] == s[2][0]:
  print("YES")
else:
  print("NO")

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = S_LIST()
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[len(a)-1] == b[0] and b[len(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):
line = input()
Line = line.split()
A = Line[0]
B = Line[1]
C = Line[2]

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):
s=input().split()
print('YNEOS'[s[0][-1]!=s[1][0] or s[1][-1]!=s[2][0]::2])

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b, c = LS()
    if a[-1] == b[0] and b[-1] == c[0]:
        print("YES")
    else:
        print("NO")
    return


def B():
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    A()

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

Solution (Python):
v = list(input().split(' '))

if v[0][len(v[0])-1] == v[1][0] and v[1][len(v[1])-1] == v[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 = map(str, input().split())

tmp = A[len(A) - 1]
tmp1 = B[0]
tmp2 = B[len(B) - 1]
tmp3 = C[0]

if tmp == tmp1 and tmp2 == tmp3:
    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 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(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[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Solution (Python):
a, b, c = (x for x 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[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()
print('YNEOS'[a[-1]!=b[0]or b[-1]!=c[0]::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):
temp_list = [x for x in input().split()]
if temp_list[0][-1] == temp_list[1][0] and temp_list[1][-1] == temp_list[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 = 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] != B[0] or B[-1] != C[0]::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 = map(str,input().split())
out = ("YES" if A[-1]==B[0] and B[-1]==C[0] else "NO")
print(out)

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 = 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 = 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 = input().split()
AL = list(A)
BL = list(B)
CL = list(C)
print("YES" if AL[len(AL)-1] == BL[0] and BL[len(BL)-1] == CL[0] else "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):

import sys
sys.setrecursionlimit(300000)

YES = "YES"  
NO = "NO"  

def solve(A: str, B: str, C: str):
    ret = NO
    if A[-1] == B[0] and B[-1] == C[0]:
        ret = YES
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = next(tokens)  
    B = next(tokens)  
    C = next(tokens)  
    solve(A, B, C)

if __name__ == '__main__':
    main()

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

print("YES") if a[len(a)-1] == b[0] and b[len(b)-1] == c[0] 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):
li = input().split()
if li[0][-1] == li[1][0] and li[1][-1] == li[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):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

A, B, C = sl()

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

a=s[0]
b=a[-1]
c=s[1]
d=c[0]
e=c[-1]
f=s[2]
g=f[0]

if b==d and e==g:
    print("YES")
else:
    print("NO")

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

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

if (a[-1]==b[0])&(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()





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

Solution (Python):
s1, s2, s3 = list(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 = 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())
len_A = len(A)
len_B = len(B)
flag = 0

if A[len_A - 1] == B[0]:
    if B[len_B - 1] == C[0]:
        flag = 1
        print("YES")

if flag == 0:
    print("NO")

Solution (Python):
a, b, c = map(str, input().split())
aList = list(a)
bList = list(b)
cList = list(c)
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):


import itertools
import collections
import bisect

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())
len_A = len(A)
len_B = len(B)
flag = 0

if A[len_A - 1] == B[0]:
    if B[len_B - 1] == C[0]:
        flag = 1
        print("YES")

if flag == 0:
    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(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 B[0] == A[(len(A)-1):] and B[(len(B)-1):] == C[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
import sys
input = sys.stdin.readline

a, b, c = input().split()
if a[-1] in b[0] and b[-1] in c[0]:
    ans = 'YES'
else:
    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):
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):
def abc():
    a, b, c = input().split()
    if a[-1] == b[0] and b[-1] == c[0]:
        print('YES')
    else:
        print('NO')


abc()

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[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 = 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 = 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 = [x for x 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 = map(str,input().split())
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

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

if word[0][-1] == word[1][0] and word[1][-1] == word[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):
a,b,c = input().split()
answer = 'NO'

if a[-1] == b[0]:
    if b[-1] == c[0]:
        answer = 'YES'

print(answer)

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

import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())


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):
x,y,z=input().split()
print("YES" if x[-1]==y[0] and y[-1]==z[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):
s1, s2, s3 = [ v for v in input().split() ]

if s1[-1] == s2[0] and s2[-1] == s3[0]:
  ans = "YES"
else:
  ans = "NO"
print(ans)

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 = raw_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 a[-1] == b[0] and b[-1] == c[0] else "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):


list_s = [string for string in input().split()]


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