100 atcoder#ABC060A. [ABC060A] Shiritori
[ABC060A] Shiritori
Score : points
Problem Statement
You are given three strings , and . Check whether they form a word chain.
More formally, determine whether both of the following are true:
- The last character in and the initial character in are the same.
- The last character in and the initial character in are the same.
If both are true, print YES
. Otherwise, print NO
.
Constraints
- , and are all composed of lowercase English letters (
a
-z
). - , where , and are the lengths of , and , respectively.
Input
Input is given from Standard Input in the following format:
Output
Print YES
or NO
.
rng gorilla apple
YES
They form a word chain.
yakiniku unagi sushi
NO
and form a word chain, but and do not.
a a a
YES
aaaaaaaaab aaaaaaaaaa aaaaaaaaab
NO