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

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

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

    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    a = LS()
    f = True
    for i in range(1,3):
        if a[i][0] != a[i-1][-1]:
            f = False
            break

    if f:
        return 'YES'

    return 'NO'


print(main())

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


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

Solution (Python):
a = raw_input()

b = a.split(' ')

if b[0][-1] == b[1][0] and b[1][-1] == b[2][0]:
  print "YES"
else:
  print "NO"

Solution (Python):
a = raw_input()

l = a.split(' ')

if l[0][-1] == l[1][0] and l[1][-1] == l[2][0]:
	print "YES"
else:
	print "NO"

Solution (Python):


ABC = input().split()


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

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

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

if a[-1] != b[0]:
    print("NO")

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

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

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

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

Solution (Python):
def is_shiritori(s):
    before_mozi = None
    for mozi in s.split():
        if before_mozi is None:
            before_mozi = mozi
            continue
        else:
            if mozi[0] is not before_mozi[-1]:
                print("NO")
                return False
            before_mozi = mozi
    print("YES")

ss = input()
is_shiritori(ss)

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

Solution (Python):
moji=raw_input().split(" ")
flag=0
for i in range(len(moji)-1):
	if(moji[i][len(moji[i])-1]!=moji[i+1][0]):
		print "NO"
		flag=1
		break
if(flag==0):
	print "YES"

Solution (Python):
a = map(str, raw_input().split(" "))
first = ""
for i in a:
    if len(first)!=0:
        if i.startswith(first) == False:
            print "NO"
            exit()
    first = i[len(i)-1]
print "YES"

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

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

Solution (Python):




import numpy as np
import itertools

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()
def check(a, b, c):
    if a[-1] == b[0] and b[-1] == c[0]:
        return True
    return False
print('YES' if check(a, b, c) else 'NO')

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

al = a[-1]
bf = b[0]
bl = b[-1]
cf = c[0]

if al==bf and bl==cf:
    print("YES")

else:
    print("NO")

Solution (Python):
l = input().split()
def shiritori (letter):
    if letter[0][-1:] == letter[1][:1]:
        if letter[1][-1:] == letter[2][:1]:
            return(print('YES'))
        else:
            return(print('NO'))
    else:
        return(print('NO'))
shiritori(l)

Solution (Python):

import os
import sys

l = sys.stdin.readline()
l.rstrip('\n')
a, b, c = l.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[len(a)-1]==b[0] and b[len(b)-1]==c[0]:
    print("YES")
else:
    print("NO")

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

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

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

if a[-1] == b[0]:
    ab = 1
if b[-1] == c[0]:
    bc = 1
if ab==1 and bc==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):
import sys

s = input().split(' ') 

def isSeritori(A,B):
    if A[-1] == B[0] :
        return True
    else:
        return False

for i in range(2):
    if (isSeritori(s[i],s[i+1])):
        continue
    else:
        print('NO')
        sys.exit(0)
print('YES')

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

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

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

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

if b[0] == a[-1] and c[0] == b[-1]:
    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 = map(str,raw_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] is B[0] and B[-1] is C[0]:
    print("YES")
else:
    print("NO")

Solution (Python):
import sys

a, b, c = sys.stdin.readline().rstrip().split()

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

Solution (Python):


mozir=input()
hyo=mozir.split(' ')

ans=True
for idx in range(0,2,1):
    ras=hyo[idx][len(hyo[idx])-1]
    cap=hyo[idx+1][0]
    if ras != cap:
        ans = False

if ans:
    print('YES')
else:
    print('NO')

Solution (Python):
l = raw_input().split(" ")

judge="YES"

if (l[0][-1] != l[1][0]):
    judge="NO"

if (l[1][-1] != l[2][0]):
    judge="NO"

print judge

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

Solution (Python):
S = input().split()
a2 = S[0][-1]
for i,s in enumerate(S):
	if i == 0:
		continue
	a1 = s[0]
	if a1 != a2:
		print("NO")
		break
	a2 = s[-1]
	if i == 2:
		print("YES")

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

Solution (Python):
abc=  input()
 
a, b, c = abc.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())
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):


import sys

def main(argv):
    for line in sys.stdin:
        a, b, c = line.split(" ", 3)
        if a[-1] == b[0] and b[-1] == c[0]:
            print("YES")
        else:
            print("NO")

if __name__ == "__main__":
    main(sys.argv)

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()
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 = list(map(str,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 = raw_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):
data = input().split()
A = data[0]
B = data[1]
C = data[2]

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

Solution (Python):
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    a = lst[0]
    b = lst[1]
    c = lst[2]

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

if __name__ == '__main__':
    sys.exit(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 = raw_input().split()

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

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

Solution (Python):


if __name__ == "__main__":
	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):
import sys
read=lambda:sys.stdin.readline().rstrip()
readi=lambda:int(sys.stdin.readline())
writeln=lambda x:sys.stdout.write(str(x)+"\n")
write=lambda x:sys.stdout.write(x)
A,B,C=read().split()
if A[-1] == B[0] and B[-1] == C[0]:
    writeln("YES")
else:
    writeln("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 = input().split()

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

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

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

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

Solution (Python):
def main():
    a,b,c = 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 = raw_input().split()

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

Solution (Python):
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

a, b, c = ns().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()
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')