Guess My Word

Time limit2sMemory limit256 MB

Problem

We describe a two-player game called "Guess My Word" (GMW). Call the two players A and B.

  • A secretly picks one word from a corpus (a list of words) that both players know. If the chosen word has length $n$, A draws $n$ horizontal segments in a row on a sheet of paper to mark where each letter will go, and places the sheet between the two players.
  • B must now discover the word by guessing letters one at a time. On each step B chooses one letter and tells it to A.
    • If that letter occurs in the word, A writes it on the correct segment(s). Once every letter of the word has been filled in, B wins.
    • If that letter does not occur in the word, A writes it below the leftmost still-empty segment. There are $n$ such slots below the segments. If all $n$ slots are already full so that the wrong letter just named cannot be written anywhere, then at that moment B loses and A wins, and A must reveal the chosen word to B.

To summarize, B may write at most $n$ wrong letters; the game is lost the instant B names a wrong letter when no empty slot remains (that is, the $(n+1)$-th wrong guess). Conversely, even after using all $n$ slots, B can still win by filling the remaining positions with correct guesses.

Because A never writes the word down and only keeps it in mind, A may secretly switch to a different word at any point during the game, as long as it does not contradict the answers already given. That is, A is not bound to any single word and may keep answering as if any corpus word consistent with all answers so far were the true one. The only requirement is that if A wins, A must be able to present, as the answer, some word that actually exists in the corpus and is consistent with every answer A gave during the game.

Because A can switch words like this, a well-chosen corpus can let A win no matter how B guesses. For example, for the corpus consisting of the two-letter words ME, MD, DE, ED, AS, IS, AI, SI, A can always win whatever letters B chooses and in whatever order.

Several corpora are given. For each corpus, decide independently whether A can always win no matter which letters B chooses and in what order.

Input

The input consists of several corpora that are processed independently.

The first line contains the number of corpora $C$, an integer with $1 \le C \le 20$. The $C$ corpora then follow one after another.

Each corpus begins with a line containing the number of words $K$, followed by $K$ distinct words. The words are separated by one or more spaces, tabs, or newlines. Every word consists only of uppercase English letters, and the length of each word is always less than $7$ (that is, between $1$ and $6$). Moreover, within a single word no letter appears more than once; all letters of a word are distinct.

The input file is smaller than 500KB. In every corpus the number of words does not exceed 1,000.

Output

For each corpus, print "Yes" on its own line if A has a strategy that always wins regardless of which letters B chooses and in what order, and "No" otherwise.

In any game that A wins, the word A finally presents as the answer must be a word that really exists in the corpus and must be consistent with every answer A gave during the game.