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

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

-print(("YNEOS"[a[::-1][0] != b[0] or b[::-1][0] != c[0] :: 2])) +print(("YNEOS"[a[-1] != b[0] or b[-1] != c[0] :: 2]))