Domino of words

You are given n 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 n, followed by n words made
up of between 1 and 10 lowercase letters. You can assume 1 ≤ n ≤ 10⁵.

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
