#include <stdio.h>
#include <string.h>
int moze(char string[],int used[],int n,char matrica[][1005])
{
    /*puts(string);
    for(int i=0; i<n; i++)
    {
       printf("%d\n",used[i]);
    }
    printf("\n");*/
    if(string[0]=='\0')
    {
        return 1;
    }
    int moz=0;
    int duzina=strlen(string);
    for(int i=0; i<n; i++)
    {
        if(!used[i])
        {
            int lenn=strlen(matrica[i]);
            if(lenn<duzina)
            {
                char pam=string[lenn];
                string[lenn]='\0';
                if(strcmp(string,matrica[i])==0)
                {
                    string[lenn]=pam;
                    used[i]=1;
                    string+=lenn;                                       
                    moz=moz || moze(string,used,n,matrica);
                    used[i]=0;                    
                }
                else string[lenn]=pam;
            }
            else
            {
                char pam=matrica[i][duzina];
                matrica[i][duzina]='\0';
                if(strcmp(matrica[i],string)==0)
                {
                    matrica[i][duzina]=pam;
                    used[i]=1;
                    strcpy(string,matrica[i]+duzina);                    
                    moz=moz || moze(string,used,n,matrica);
                    used[i]=0;
                }
                else matrica[i][duzina]=pam;
            }
        }        
    }
    return moz;
}
int main()
{
    freopen("recnik.in","r",stdin);
    freopen("recnik.out","w",stdout);
    int t;
    scanf("%d",&t);
    for(int i=0; i<t; i++)
    {
        int n;
        scanf("%d",&n);
        
        getchar();
        
        int used[105];
        for(int j=0; j<105; j++)
        {
            used[j]=0;
        }
        
        char matrica[105][1005];
        for(int j=0; j<n; j++)
        {
            gets(matrica[j]);
        }        
        
        char string[1005];
        
        bool dvosm=false;
        
        for(int j=0; j<n; j++)
        {
            strcpy(string,matrica[j]);
            used[j]=1;
            if(moze(string,used,n,matrica))
            {
                dvosm=true;
                break;
            }
            used[j]=0;
        }
        
        if(dvosm) printf("dvosmislen\n");
        else printf("nedvosmislen\n");
               
    }
}
