Domino of words

You are given nn 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

Input consists of several cases, each with nn, followed by nn words made up of between 1 and 10 lowercase letters. You can assume 1n1051 \le n \le 10^5.

Output

For every case, print “yes” if it is possible arrange all the words like in the game of domino. Otherwise, print “no”.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:24:46.794Z

© Jutge.org, 2006–2026.
https://jutge.org