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();print('NYOE S'[a[-1]==b[0]and b[-1]==c[0]::2])

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):
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[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())
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=[i for i in input().split()]
l1=len(a)
l2=len(b)
l3=len(c)
if a[l1-1]==b[0] and b[l2-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 copy
import random
import bisect 
import fractions 
import math

mod = 10**9+7

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("YNEOS"[a[-1]!=b[0] or b[-1]!=c[0]::2])

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

current = ''
for word in words:
    if current == '':
        current = word
        continue

    if current[-1] == word[0]:
        current = word
    else:
        print('NO')
        break
else:
    print('YES')

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("YNEOS"[A[-1]!=B[0]or B[-1]!=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,b,c = input().split()

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

Solution (Python):
import sys

input = sys.stdin.readline


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

    print(ans)


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):
lis=list(input().split())
if lis[0][-1]==lis[1][0] and lis[1][-1]==lis[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):





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 Shiritori(x,y,z):

    len_x = len(x)
    len_y = len(y)
    len_z = len(z)

    if x[len_x-1] == y[0]:
        if y[len_y - 1] == z[0]:
            return "YES"
        else:
            return "NO"
    else:
            return "NO"

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

FLAG = Shiritori(A,B,C)

print(FLAG)

Solution (Python):
A,B,C = map(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 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):
Nstr = input().split()
result = 'YES'
for i in range(2):
    if Nstr[i][-1] != Nstr[i + 1][0]:
        result = 'NO'
print(result)

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();print("YNEOS"[a[-1]!=b[0] or b[-1]!=c[0]::2])

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

Solution (Python):

def read_input():
    a, b, c = input().strip().split()
    return a, b, c

def submit():
    a, b, c = read_input()

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



if __name__ == '__main__':
    submit()

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())
flag = 0
if A[-1] != B[0]:
    print("NO")
    exit()
if 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):
w=input().split()
if w[0][-1]==w[1][0] and w[1][-1]==w[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[-1] == b[0] and b[-1] == c[0] else "NO")

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

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

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]:
    ans = 'YES'
else:
    ans = 'NO'

print(ans)

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

Solution (Python):
import sys, os
import numpy as np

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

solve()

Solution (Python):

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

Solution (Python):
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


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


def inlf():
    return list(map(float, input().split()))


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


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

a, b, c = inls()

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

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

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

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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

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

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

Solution (Python):
A,B,C=input().split();print('YNEOS'[(A[-1]!=B[0])|(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=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):
import sys

def main():
    input = sys.stdin.readline
    A, B, C = map(str, input().split())

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


if __name__ == '__main__':
    print(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):
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 = 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()

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 = 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):
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_SM(n):
	return [tuple(INSTR_S()) for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

A, B, C = INSTR_S()
print("YNEOS"[not(A[-1]==B[0] and B[-1]==C[0])::2])

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 = map(list,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):
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=input().split()
for i in range(1,3):
    if a[i-1][-1] != a[i][0]:
        print('NO')
        exit()
print('YES')

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

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


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



""""
n,T = LI()
ans = 0
t = LI()
for i in range(n-1):
    ans += min(T,t[i+1]-t[i])
ans += T
print(ans)
"""


"""
n,w = LI()
g = LIR(n)
l = [[] for i in range(4)]
for W,v in g:
    l[W-g[0][0]].append(v)
    l[W-g[0][0]].sort(reverse = True)
l0 = len(l[0])
l1 = len(l[1])
l2 = len(l[2])
l3 = len(l[3])
for i in range(l0-1):
    l[0][i+1] += l[0][i]
l[0].insert(0,0)
for i in range(l1-1):
    l[1][i+1] += l[1][i]
l[1].insert(0,0)
for i in range(l2-1):
    l[2][i+1] += l[2][i]
l[2].insert(0,0)
for i in range(l3-1):
    l[3][i+1] += l[3][i]
l[3].insert(0,0)
ans = 0
for i in range(l0+1):
    for j in range(l1+1):
        for k in range(l2+1):
            for m in range(l3+1):
                if i*g[0][0]+j*(g[0][0]+1)+k*(g[0][0]+2)+m*(g[0][0]+3) <= w:
                    ans = max(ans,l[0][i]+l[1][j]+l[2][k]+l[3][m])
print(ans)
"""

Solution (Python):
def shiritori(A: str, B: str, C: str) -> bool:
    return A[-1] == B[0] and B[-1] == C[0]


if __name__ == "__main__":
    A, B, C = input().split()
    yes = shiritori(A, B, C)
    print('YES' if yes else 'NO')

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

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

Solution (Python):
A,B,C=map(list,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):
s=input().split();print('YNEOS'[s[0][-1]!=s[1][0]or s[1][-1]!=s[2][0]::2])

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

ans = 'NO'
if a[-1] == b[0] and b[-1] == c[0]:
    ans = 'YES'

print(ans)

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 = [_ for _ 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=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):
As=[[j for j in i] for i in input().split()]
if As[0][-1] == As[1][0] and As[1][-1] == As[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[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 = (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[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(' '))
ans = 'YES' if A[-1]==B[0] and B[-1]==C[0] else '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):
def func():
    A, B, C = input().split()
    result = 'YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO'
    return result

print(func())

Solution (Python):
a,b,c=(str(x) for x in 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('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 = list(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()
ans = "NO"
if A[-1] == B[0] and B[-1] == C[0]:
  ans = "YES"
print(ans)

Solution (Python):
A, B, C = 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=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 = input()
s = [elm[0] for elm in x.split()[1:]]
e = [elm[-1] for elm in x.split()[:-1]]
if s == e:
    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):


"""
Shiritori
"""

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

Solution (Python):

import sys

def main():
	a, b, c = input().split(" ")
	aa = list(a)
	bb = list(b)
	cc = list(c)
	
	if aa[len(aa)-1] == bb[0] and bb[len(bb)-1] == cc[0]:
		print("YES")
	else:
		print("NO")
	
if __name__ == "__main__":
	main()

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=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):
from sys import stdin
a, b, c = stdin.readline().rstrip().split()
if list(a)[-1] == list(b)[0] and list(b)[-1] == list(c)[0]:
  print('YES')
else:
  print('NO')

Solution (Python):
a,b,c=[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=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 = list(s[0])
B = list(s[1])
C = list(s[2])

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]) & (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):
L = list(input().split())
for i in range(len(L)-1):
    if L[i][-1]  != L[i+1][0]:
        print("NO")
        break
else:
  print("YES")

Solution (Python):
L = list(input().split())
val = 0
for i in range(len(L)-1):
    if L[i][-1]  != L[i+1][0]:
        print("NO")
        break
else:
  print("YES")

Solution (Python):
L = list(input().split())
val = 0
for i in range(len(L)-1):
    if L[i][-1]  != L[i+1][0]:
        print("NO")
        quit()
print("YES")

Solution (Python):
a,b,c = input().split()
a_left=a[0]
a_right=a[-1]
b_left=b[0]
b_right=b[-1]
c_left=c[0]
c_right=c[-1]
if a_right == b_left and b_right == c_left:
  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 = 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):
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=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[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().rstrip().split()
if a[-1:] == b[0:1] and b[-1:] == c[0:1] :
  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()
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() ]

ans = A[-1] == B[0] and B[-1] == C[0]

print("YES" if ans else "NO")
print()

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

print(result)

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

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

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

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