#include <iostream>
#include <map>
#include <cstring>
#include <stdio.h>
using namespace std;

#define MaxN 110
#define MaxLen 1010

int T;
int n;
char s[MaxN][MaxLen];
int len[MaxN];
bool ok;
map <string,bool> ma;

class ClassTrie {
    ClassTrie *sl[26];
    bool mark[ 26 ];
    bool kraj;

  public:
    void Init()
    {
        memset(mark,0,sizeof(mark));
        kraj = false;
    }

    void Delete()
    {
        for (int i = 0; i < 26; i++) {
           if ( !mark[i] ) continue;
           sl[i]->Delete();
        }

        delete( this );
    }

    void Add( int p, int ps, int ks )
    {
        if ( ps == ks ) {
            if ( kraj ) ok = false;
            else kraj = true;
            return;
        }


        if ( !mark[ s[p][ps]-'a' ] ) {
            mark[ s[p][ps]-'a' ] = true;
            sl[ s[p][ps]-'a' ] = new(ClassTrie);
            sl[ s[p][ps]-'a' ]->Init();
            sl[ s[p][ps]-'a' ]->Add( p, ps+1, ks );
        }
        else {
            sl[ s[p][ps]-'a' ]->Add( p, ps+1, ks );
        }
    }

    bool Do( ClassTrie *trie, char tr[MaxN], int len )
    {
        //printf("%s\n",tr);
        //system("pause");
        bool ret = false;
        if ( kraj ) ret = trie->Find( trie, tr, 0, len );
        if ( ret ) return true;
        for (int i = 0; i < 26; i++)
           if ( mark[i] ) {
              tr[ len++ ] = i+'a';
              tr[ len ] = '\0';
              if ( sl[i]->Do( trie, tr, len ) ) return true;
           }

        return false;

    }

    bool Find( ClassTrie *trie, char tr[MaxN], int ptr, int len )
    {
        if ( this == trie ) {
            if ( ma[ string(tr) ] ) return false;
            ma[ string(tr) ] = true;
        }
        /*for (int i = 0; i < 26; i++)
           printf("%c %d\n",i+'a',mark[i]);*/
        //printf("FIND:%s %d %d\n",tr,ptr,len);

        if ( ptr == len ) {
            //printf("%d\n",kraj);
            if ( kraj ) return true;
            tr[0] = '\0';
            return (*this).Do( trie, tr, 0 );
        }

        if ( !mark[ tr[ ptr ]-'a' ] ) return false;

        return sl[ tr[ ptr ]-'a' ]->Find( trie, tr, ptr+1, len );
    }

};

ClassTrie *trie;

bool Solve( int p1, int p2 )
{
    for (int i = 0; i < min( len[p1], len[p2] ); i++)
       if ( s[p1][i] != s[p2][i] ) return false;

    char tr[MaxLen];
    tr[0] = '\0';

    if ( len[p1] < len[p2] ) {
        for (int i = len[p1]; i < len[p2]; i++)
           tr[i-len[p1]] = s[p2][i];
        tr[len[p2]-len[p1]] = '\0';
    }
    else {
        for (int i = len[p2]; i < len[p1]; i++)
           tr[i-len[p2]] = s[p1][i];
        tr[len[p1]-len[p2]] = '\0';
    }
    //printf("SOLVE %d %d\n",p1,p2);
    return trie->Find( trie, tr, 0, strlen(tr) );
}

int main()
{
    freopen("recnik.in","r",stdin);
    freopen("recnik.out","w",stdout);

    scanf("%d",&T);

    for (int t = 0; t < T; t++) {
        ma.clear();

        trie = new( ClassTrie );
        trie->Init();

        ok = true;

        scanf("%d",&n);
        for (int i = 0; i < n; i++) {
            scanf("%s",s[i]);
            len[i] = strlen(s[i]);
            trie->Add( i, 0, len[i] );
        }

        for (int i = 0; i < n; i++) {
           if ( !ok ) break;
           for (int j = i+1; j < n; j++) {
              if ( Solve( i, j ) == true ) { ok = false; break; }
           }
        }

        if ( ok ) printf("nedvosmislen\n");
        else      printf("dvosmislen\n");

        trie->Delete();

    }

    fclose(stdin);
    fclose(stdout);

    return 0;
}
