const max = 500000;
      root = 0;
type slog = record p,d,pok: longint;end;
     slog1 = record d: char;rec: boolean;end;
var i,j,x,y,n,m,t,tp,e,nc,ti,tcv,tcv2,delta,tr: longint;
    g: array[0..max] of slog;
    cvor: array[0..max] of slog1;
    idx,posl: array[0..max] of longint;
    reci: array[1..100,1..1000] of char;
    l: array[1..100] of integer;
    s: string;
    c: char;
    nasao,drugi: boolean;
begin
     assign(input,'recnik.in');
     reset(input);
     assign(output,'recnik.out');
     rewrite(output);
     readln(t);
     for tp:=1 to t do
      begin
       readln(n);
       x:=root;
       fillchar(l,sizeof(l),0);
       fillchar(g,sizeof(g),0);
       fillchar(cvor,sizeof(cvor),0);
       fillchar(idx,sizeof(idx),0);
       fillchar(posl,sizeof(posl),0);
       e:=0;
       nc:=0;
       for i:=1 to n do
        begin
         x:=root;
         while not eoln do
          begin
           read(c);
           l[i]:=l[i]+1;
           reci[i,l[i]]:=c;
           nasao:=false;
           j:=idx[x];
           while j<>0 do
            begin
             if cvor[g[j].d].d=c then
              begin
               x:=g[j].d;
               if eoln then cvor[x].rec:=true;
               nasao:=true;
               break;
              end;
             j:=g[j].pok;
            end;
           if not nasao then
            begin
             e:=e+1;
             nc:=nc+1;
             if idx[x]=0 then idx[x]:=e
             else g[posl[x]].pok:=e;
             posl[x]:=e;
             g[e].p:=x;
             g[e].d:=nc;
             cvor[nc].d:=c;
             if eoln then cvor[nc].rec:=true;
             x:=nc;
            end;
          end;
         readln;
        end;
       for i:=1 to n do
        begin
         for j:=i+1 to n do
          begin
           nasao:=false;
           ti:=1;
           tcv:=root;
           drugi:=false;
           while (true) and not drugi do
            begin
             for x:=ti to l[i] do
              begin
               y:=idx[tcv];
               while y<>0 do
                begin
                 if cvor[g[y].d].d=reci[i,x] then
                  begin
                   tcv:=g[y].d;
                   if (x<>l[i]) and (cvor[g[y].d].rec) then
                    begin
                     drugi:=true;
                     ti:=x;
                     break;
                    end;
                   break;
                  end;
                 y:=g[y].pok;
                end;
               if drugi then break;
              end;
             if not drugi then break;
             tcv2:=root;
             tr:=i;
             delta:=0;
            if x=l[i] then
             begin
              delta:=-l[i];
              tr:=j;
             end;

             for x:=ti+1 to l[i]+l[j] do
              begin
               y:=idx[tcv2];
               while y<>0 do
                begin
                 if cvor[g[y].d].d=reci[tr,x+delta] then
                  begin
                   tcv2:=g[y].d;
                   if (cvor[g[y].d].rec) and (x=l[i]+l[j]) then
                    begin
                     nasao:=true;
                     break;
                    end;
                   break;
                  end;
                 y:=g[y].pok;
                end;
               if x=l[i] then
                  begin
                   delta:=-l[i];
                   tr:=j;
                  end;
               if nasao then break;
              end;
             if nasao then break;
            end;
           if nasao then break;
          end;
         if nasao then break;
        end;
       if nasao then writeln('dvosmislen')
       else writeln('nedvosmislen');
      end;
     close(input);
     close(output);
end.
