#abc060a. [abc060_a]Shiritori
[abc060_a]Shiritori
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
.
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
and form a word chain, but and do not.
Sample Input 3
a a a
Sample Output 3
YES
Sample Input 4
aaaaaaaaab aaaaaaaaaa aaaaaaaaab
Sample Output 4
NO