//fibonici string again
#include<stdio.h>
#include<stdlib.h>
long int i,j;
int main()
{
int t;
scanf("%d",&t);
getchar();// toa absorb the /n of the previous scanf
while(t--)
{
i=j=0;
long int count[27]={0};
long int flag=0,temp=0;
char ch=0,arr[100000];
int alpha[27]={0};
scanf("%s",arr);
while(arr[i]!='\0')
{
// ch=getchar();
// if(ch<97||ch>122)
// break;
for(j=0;j<flag;j++)
{
if(arr[i]==alpha[j])
{
count[j]+=1;
break;
}
}
if(j==flag)
{
alpha[j]=arr[i];
count[j]=1;
flag++;
}
i++;
}
// printf(“the array has stored \n”);
// for(i=0;i<flag;i++)
// printf("%c==%ld\n",alpha[i],count[i]);
// now we will sort the array
for(i=0;i<(flag-1);i++)
{
for(j=(i+1);j<flag;j++)
{
if(count[i]>count[j])
{
temp=count[i];
count[i]=count[j];
count[j]=temp;
}
}
}
// after sorting the array becomes
// for(i=0;i<flag;i++)
// printf("%ld ",count[i]);
if(flag<3)
{
printf("Dynamic\n");
continue;
}
for(i=0;i<(flag-2);i++)
{
if(count[i]+count[i+1]==count[i+2])
continue;
else
{
printf("Not\n");
break;
}
}
if(i==(flag-2))
printf("Dynamic\n");
}
}