You are given words. Can you permute the words (not their letters) so that the second word begins with the last letter of the first word, the third word begins with the last letter of the second word, and so on?
Input consists of several cases, each with , followed by words made up of between 1 and 10 lowercase letters. You can assume .
For every case, print “yes” if it is possible arrange
all the words like in the game of domino. Otherwise, print
“no”.
Input
3 the easiest task 2 or not 1 hello 2 ab abc 5 za z zz zz bz 3 a a a
Output
yes no yes no yes yes