100 atcoder#ABC060A. [ABC060A] Shiritori

[ABC060A] Shiritori

Score : 100100 points

Problem Statement

You are given three strings AA, BB and CC. Check whether they form a word chain.

More formally, determine whether both of the following are true:

  • The last character in AA and the initial character in BB are the same.
  • The last character in BB and the initial character in CC are the same.

If both are true, print YES. Otherwise, print NO.

Constraints

  • AA, BB and CC are all composed of lowercase English letters (a - z).
  • 1A,B,C101 \leq |A|, |B|, |C| \leq 10, where A|A|, B|B| and C|C| are the lengths of AA, BB and CC, respectively.

Input

Input is given from Standard Input in the following format:

AA BB CC

Output

Print YES or NO.

rng gorilla apple
YES

They form a word chain.

yakiniku unagi sushi
NO

AA and BB form a word chain, but BB and CC do not.

a a a
YES
aaaaaaaaab aaaaaaaaaa aaaaaaaaab
NO