from collections import Counter
for _ in range(int(input())):
s=input()
a=list(s)
l=[]
l1=[]
flag=0
count=1
#print(Counter(a))
a1=Counter(a)
v=(max(a1))
for k in a1:
#print(a1[k])
l1.append(a1[k])
#print("l1",l1)
y=max(l1)
#print("y",y)
l1.remove(y)
#print("l1",l1)
if len(l1)<2:
print("Dynamic")
flag=1
for i in range(len(l1)-1):
for j in range(i+1,len(l1)):
#print(l1[i],l1[j])
#print(l1[i]+l1[j],y)
if (l1[i]+l1[j])==y:
print("Dynamic")
flag=1
break
if flag==1:
break
if flag==0:
print("Not")