Question
Word Chain Pattern Check
Leo has a sequence of N words and wants to ensure they follow a special pattern: each word, starting from the second one, must begin with the last letter of the previous word and must not repeat any word used earlier. Given the list of words, can you determine if they follow Leo’s pattern? Print “Yes” if they do, otherwise print “No.”
Input
The first line of the input contains a single integer N.
Each of the next N lines contains a string Si
Constraints
2 ≤ N ≤ 105
1 ≤ |Si| ≤ 100
Each of the next N lines contains a string Si
Constraints
2 ≤ N ≤ 105
1 ≤ |Si| ≤ 100
Output
Print(without quotes)“Yes” if they do, otherwise print “No.”
Example
Sample Input
3
newton
school
discord
Sample Output
No
Explanation
2nd and 3rd word doesn't start with the previous word ending letter.
Sample Input
3
yash
hsay
yay
Sample Output
Yes
3
newton
school
discord
Sample Output
No
Explanation
2nd and 3rd word doesn't start with the previous word ending letter.
Sample Input
3
yash
hsay
yay
Sample Output
Yes