You are given three strings, A, B, and C. Your task is to determine if they form a word chain based on the following criteria:
The last character of string A and the first character of string B must be the same.
The last character of string B and the first character of string C must be the same.
If both conditions are satisfied, print YES. Otherwise, print NO.
Input Format
Three strings, A, B, and C, each containing only uppercase or lowercase alphabetical characters.
Each string will have a length of at least 1 and at most 100.
Output Format
Print YES if the strings form a word chain, and NO otherwise.
Examples
Example 1:
Input:
text
apple
egg
grape
Output:
text
YES
Example 2:
Input:
text
cat
dog
goat
Output:
text
NO
Example 3:
Input:
text
hello
octopus
star
Output:
text
NO
Example 4:
Input:
text
open
note
elephant
Output:
text
YES
Implementation
The solution should be implemented in the /app/ directory. Make sure to handle all edge cases and validate that input strings meet the specified criteria.
Important: place your implementation at /app/solution.py so the verifier can run it.