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):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

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

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

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

Solution (Python):
a,b,c=input().split()
a1=len(a)
b1=len(b)
if a[a1-1]==b[0] and b[b1-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=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())
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 = input().split()

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

L=input().rstrip().split(" ")
a=L[0]
b=L[1]
c=L[2]
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()
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(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):
str = input()

a = str.split(" ")

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

Solution (Python):

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


if '__main__' == __name__:
    resolve()

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())
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 = list(map(str, input().split()))

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

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

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

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

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

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

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):
s = list(map(str, 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=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):
icase=0    
if icase==0:
    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 = 'YES' if A[-1] == B[0] and B[-1] == C[0] else '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):
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()

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

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

Solution (Python):
l = input().split()
if l[0][-1] == l[1][0] and l[1][-1] == l[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):
n, m, k = input().split()
if n[len(n)-1] == m[0] and m[len(m)-1] == k[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 = 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 = 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("NYOE S"[a[-1]+b[-1]==b[0]+c[0]::2])

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

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):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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


if __name__ == '__main__':
    main()

Solution (Python):
A,B,C=input().split()
a,b=len(A),len(B)
if(A[a-1]==B[0] and B[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()
if a[-1]==b[0] and b[-1]==c[0]:
    print('YES')
else:
    print('NO')

Solution (Python):
a = input().split()
ans = 'YES'
for i in range(len(a)-1):
    if a[i][-1] != a[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):
a, b, c = map(str, input().split())
r = 'NO'
if a[-1] == b[0] and b[-1] == c[0]:
	r = 'YES'
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):
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=map(str,input().split())



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

Solution (Python):
def main():
  s1,s2,s3 = map(str,input().split())
  ans = False
  if s1[len(s1)-1] == s2[0]:
    if s2[len(s2)-1]==s3[0]:
      ans = True
  print("YES" if ans else "NO")
if __name__ == '__main__':
  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 = 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()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Solution (Python):
import sys

s = sys.stdin.readline().split()

def main():
    ans = 'YES'
    for i in range(2):
        if s[i][-1] != s[i+1][0]:
            ans = 'NO'
            break
    print(ans)

if __name__ ==  '__main__':
    main()

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c = ism()

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):
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [str(i) for i in 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 = input().split()

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

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

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('YNEOS'[A[-1]!=B[0]or B[-1]!=C[0]::2])

Solution (Python):
A,B,C=map(str,input().split())
a=list(A)
b=list(B)
c=list(C)
print("YES" if a[len(a)-1]==b[0] and b[len(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 = 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 B[0] == A[len(A) - 1] and C[0] == B[len(B) - 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=map(str,input().split())
x=len(A)
y=len(B)
if A[x-1]==B[0] and B[y-1]==C[0]:
  print("YES")
else:
  print("NO")

Solution (Python):
import math



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

flag = False

if a[-1] == b[0]:
  if b[-1] == c[0]:
    flag = True

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

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

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b, c = nas()

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

Solution (Python):
A=list(map(str, input().split()))
a=['']*3
b=['']*10
tmp1=''
tmp2=''
p=0
for i in range(3):
    a[i]=list(A[i])
    if i!=0:
        tmp2=a[i][0]
    if tmp1!='':
        if tmp1!=tmp2:
            p=1
    a[i]=list(reversed(a[i]))
    b=list(a[i])
    tmp1=b[0]
if p==0:
    print('YES')
else:
    print('NO')

Solution (Python):
import math

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

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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 = 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=raw_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]:
  if b[-1] == c[0]:
    print("YES")
  else:
    print("NO")  
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 = [i for i in 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=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[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]:
    if b[-1]==c[0]:
        print("YES")
    else:
        print("NO")
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()
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[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 = list(input().split())
print('YES' if a[len(a)-1] == b[0] and b[len(b)-1] == c[0] else 'NO')

Solution (Python):

import sys


YES = "YES"  
NO = "NO"  


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


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().strip().split()

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

Solution (Python):


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    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):


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[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):
word=input().split()
if word[0][-1]==word[1][0] and word[1][-1]==word[2][0]:
    ans="YES"
else:
    ans="NO"
print(ans)

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

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

Solution (Python):
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def func(N, mod):
    F = [1]
    for i in range(1, N + 1):
        F.append(F[-1] * i % mod)
    return F


def inv(a, mod):
    return pow(a, mod - 2, mod)


def C(F, a, b, mod):
    return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod


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


if __name__ == "__main__":
    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):
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 = 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")