#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
int suma, t, n, vre[334];
char c, s[111][1111], s1[2222], s2[2222];

int main() {
    FILE *ff = fopen("recnik.in", "r");
    FILE *gg = fopen("recnik.out", "w");
    vre[0] = 0;
    suma = 0;
    fscanf(ff, "%d", &t);
    for (int ttt = 1; ttt <= t; ttt++) {
    int res = 0;
    fscanf(ff, "%d%c", &n, &c);
    for (int i = 1; i <= n; i++) {
        fscanf(ff, "%s", &s[i]);
        vre[i] = strlen(s[i]);
        //printf("%d\n", vre[i]);
        suma +=  vre[i];
    }
    suma /= n;
    for (int i = 1; i <= n-1; i++) {
        for (int j = i+1; j <= n; j++) {
            int tacno = 1;
            int n1 = vre[i];
            int n2 = vre[j];
            if (n1 == n2) {
                for (int k = 0; k < n1; k++) if (s[i][k] != s[j][k]) tacno = 0;
                if (tacno) res = 1;
            }

            tacno = 1;
            for (int k = 0; k < n1; k++) {
                s1[k] = s[i][k];
                s2[n2+k] = s[i][k];
            }
            for (int k = 0; k < n2; k++) {
                s1[n1+k] = s[j][k];
                s2[k] = s[j][k];
            }
            for (int k = 0; k < n1+n2; k++) if (s1[k] != s2[k]) tacno = 0;
            if (tacno) res = 1;
        }
    }


    if ((suma * n*n*n*n) < 5000000) {
        for (int i = 0; i <= n; i++)
            for (int j = 1; j <= n; j++)
                for (int ii = 1; ii <= n; ii++)
                    for (int jj = 1; jj <= n; jj++)
                        if ((i != ii) && (vre[i] + vre[j] == vre[ii] + vre[jj])) {
                            //printf("RADI   i = %d j = %d ii = %d jj = %d\n", i, j, ii, jj);
                            int tacno = 1;
                            int n1 = vre[i];
                            int n2 = vre[j];
                            for (int k = 0; k < n1; k++) s1[k] = s[i][k];
                            for (int k = 0; k < n2; k++) s1[k+n1] = s[j][k];
                            n1 = vre[ii];
                            n2 = vre[jj];
                            for (int k = 0; k < n1; k++) s2[k] = s[ii][k];
                            for (int k = 0; k < n2; k++) s2[k+n1] = s[jj][k];

                            for (int k = 0; k < n1+n2; k++) if (s1[k] != s2[k]) tacno = 0;
                            if (tacno) res = 1;
                        }
    }


    if (res) fprintf(gg, "dvosmislen\n");
    else fprintf(gg, "nedvosmislen\n");
}
}
