# include <iostream>
# include <vector>

using namespace std;

const int MaxN = 105;
const int MaxLen = 1005;


int n;
int nxt;
int sz[MaxN];
int endIdx[MaxN];
char str[MaxN][MaxLen];

bool found;
bool mark[MaxN * MaxLen][MaxN];

struct Trie {
       struct Node {
           int idx;
           bool end;
           Node * adj[26];
           
           Node( bool t = false ) {
                 end = t;
                 for ( int i = 0; i < 26; i++ )
                     adj[i] = NULL;
           }
       } * root;
       
       void Delete( Node * node ) {
            for ( int i = 0; i < 26; i++ ) {
                if ( node->adj[i] != NULL ) {
                     Delete( node->adj[i] );
                     delete node->adj[i];
                }
            }
       }
       
       void init() {
            if ( root != NULL ) {
               Delete( root );
               delete root;
            }
            
            root = new Node();
            root->idx = 0;
       }
       
       void insert2( Node * node, int idx, int pos ) {
            if ( node->adj[str[idx][pos]-'a'] == NULL ) {
                 node->adj[str[idx][pos]-'a'] = new Node();
                 node->adj[str[idx][pos]-'a']->idx = nxt++;
                 
                 if ( pos == sz[idx] - 1 ) {
                    node->adj[str[idx][pos]-'a']->end = true;
                    endIdx[idx] = nxt - 1;
                 } else
                    insert2( node->adj[str[idx][pos]-'a'], idx, pos + 1 );
            } else {
                 if ( pos == sz[idx] - 1 ) {
                    node->adj[str[idx][pos]-'a']->end = true;
                    endIdx[idx] = node->idx;
                 } else insert2( node->adj[str[idx][pos]-'a'], idx, pos + 1 );
            }
       }
       
       void insert( int idx ) {
            insert2( root, idx, 0 );
       }
       
       void rek( Node * node, int idx ) {
            if ( mark[node->idx][idx] ) return;
            
            mark[node->idx][idx] = true;
            Node * nNode = node;
            for ( int i = 0; i < sz[idx]; i++ ) {
                if ( nNode->adj[str[idx][i]-'a'] != NULL )
                   nNode = nNode->adj[str[idx][i]-'a'];
                else
                   nNode = root;
            }
            
            if ( nNode == root ) return;
            if ( nNode->end && nNode->idx != endIdx[idx] ) {
                 found = true;
                 return;
            }
            
            for ( int i = 0; i < n && !found; i++ )
                rek( nNode, i );
       }
       
       void go( int idx ) {
            rek( root, idx );
       }
} trie;

int test;

int main() {
    freopen( "recnik.in", "r", stdin );
    freopen( "recnik.out", "w", stdout );
    
    for ( scanf( "%d", &test ); test; test-- ) {
        nxt = 1;
        trie.init();
        found = false;
        
        scanf( "%d", &n );
        for ( int i = 0; i < n; i++ ) {
            scanf( "%s", &str[i] );
            sz[i] = strlen( str[i] );
            trie.insert( i );
        }
        
        memset( mark, 0, sizeof( mark ) );
        for ( int i = 0; i < n && !found; i++ ) trie.go( i );
        
        if ( found ) printf( "dvosmislen\n" );
        else printf( "nedvosmislen\n" );
    }
    
    return 0;
}
