#include<stdio.h>
#include<string.h>
#include<list>

using namespace std;

#define MAXN 100
#define MAXL 1000

FILE *f, *fo;

int t;

int n;

list<pair<int,int> > v[MAXN][MAXL];

char s[MAXN][MAXL];
int l[MAXN];

int p[MAXN][MAXL];

int x[MAXN*MAXL];
int y[MAXN*MAXL];

bool vis[MAXN][MAXL];

int ls;


int i, j, k, q;

int main()
{
 
 f = fopen("recnik.in", "r");
 fo = fopen("recnik.out", "w");
 
 fscanf(f, "%d", &t);
 
 while(t--)
 { 
  fscanf(f, "%d\n", &n);
  
  for(i = 0; i < n; i++)
  {
   fgets(s[i], MAXL + 1, f);
   l[i] = strlen(s[i]) - 1;
  }
  
  for(i = 0; i < n; i++)
  {
   k = 0;
   for(j = 1; j < l[i]; j++)
   {
    while(k>0 && s[i][j] != s[i][k])
     k = p[i][k - 1];
     
    if(s[i][j] == s[i][k])
     k++;
    
    p[i][j] = k;
        
    //printf("%d ", p[i][j]);
   }
   //getchar();
  }
  
  for(i = 0; i < n; i++)
   for(j = 0; j < MAXL; j++)
   {
    v[i][j].clear();
    vis[i][j] = false;
   }
   
  for(i = 0; i < n; i++)
  for(q = 0; q < n; q++)
  if(q != i)
  {
   k = 0;
   for(j = 0; j < l[i]; j++)
   {
    while(k>0 && s[i][j] != s[q][k])
     k = p[q][k - 1];
     
    if(s[i][j] == s[q][k])
     k++;
    
    if(k == l[q])
    {
     v[i][j - k + 1].push_back(make_pair(i, j + 1));
     //printf("%d %d, %d %d : %d\n", i, j - k + 1, i, j +1, q);
    }
   }
   
   if(k > 0)
   {    
    v[i][j - k].push_back(make_pair(q, k));    
    //printf("%d %d, %d %d : %d\n", i, j - k, q, k, q);
   }
   //getchar();
  }
    
  ls = 0;
  
  for(i = 0; i < n; i++)
  {
   x[ls] = i;
   y[ls++] = 0;
   vis[i][0] = true;
  }
  
  j = 0;
  
  
  while(y[j] != l[x[j]] && j < ls)
  {
   for(list<pair<int,int> >::iterator it = v[x[j]][y[j]].begin(); it !=   v[x[j]][y[j]].end(); it++)
    if(!vis[it->first][it->second])
    {
     vis[it->first][it->second] = true;
     x[ls] = it->first;
     y[ls++] = it->second;
    }
    j++;
  }
  if(y[j] == l[x[j]])
   fprintf(fo, "dvosmislen\n");
  else 
   fprintf(fo, "nedvosmislen\n");   
 } 
 //getchar();
 return 0;
}
