For a string S let the unique set of characters that occur in it one or more times be C. Consider a permutation of the elements of C as (c1,c2,c3…). Let f(c) be the number of times c occurs in S.

If any such permutation of the elements of C satisfies f(ci)=f(ci−1)+f(ci−2) for all i≥3, the string is said to be a dynamic string.

Mr Hardik is given the task to check if the string is dynamic, but he is busy playing with sandpaper. Would you help him in such a state?

Note that if the number of distinct characters in the string is less than 3, i.e. if |C|<3, then the string is always dynamic.

**Input:**
First line contain T, number of testcases. Then the testcases
Each testcase contains of a single line of input, a string S.
**Output:**
For each testcase, output print "Dynamic" if the given string is dynamic, otherwise print "Not". (Note that the judge is case sensitive)

#include <stdio.h> #include <string.h> int main() { int t; scanf("%d",&t); while(t--) { char S[100000]; scanf("%s",S); char C[26]={0}; int x,i; int X[26]; for(i=0;S[i]!='\0';i++) { x=S[i]-'a'; C[x]++; } int count=0,j=0; for(i=0;i<26;i++) { if(C[i]!=0) { X[j]=C[i]; count++; j++; } } if(count<3) { printf("Dynamic\n"); continue; } int round,temp,flag; for(round=1;round<=count-1;round++) { flag=0; for(i=0;i<=count-1-round;i++) { if(X[i]>X[i+1]) { flag=1; temp=X[i]; X[i]=X[i+1]; X[i+1]=temp; } } if(flag==0) break; } int yo=0; for(i=count-1;i<count;i++) { if(X[i]!=X[i-1]+X[i-2]) { yo=1; break; } } if(yo==1) { printf("Not\n"); flag=1; } else printf("Dynamic\n"); } return 0; }

**INPUT_1:**

2

ffffgff

ggttrr

**OUTPUT:**

Dynamic

Not

**INPUT_2:**

5

hthehth

feeeefe

tttyyyt

uuuiuii

ccyycci

**OUTPUT:**

Not

Dynamic

Dynamic

Dynamic

Not

**ILLUSTRATION**

**Morae Q!**

- Conversion of days into year, weeks and days.
- Find if the number is a perfect number or not.
- Compute conversion of Binary to Octal.
- Return the sum of digits in a number.
- Find if a word exists or not in a sentence.
- Convert Numbers into Words.
- Read a word if it consists only of the letters known.
- Check if the string is a dynamic string or not.
- Convert all Uppercase letters to Lowercase and vice-versa.
- Change the string such that there are no matching adjacent characters.
- Find the number of sub-strings which start and end both in 1.
- Find the start and end index of unsorted sub-array.
- Find the maximum number of pairs that can be formed.
- Figure out the number of bubbly words present.
- Check if a string is lapindrome or not even with a middle character.
- Seating layout in a triangular shaped class according to the number of rows.
- Find and Sort a sub-array which makes whole array sorted.
- Seating layout according to the number of rows.
- Find the final states of the bulbs.
- Check if reversing sub array makes the array sorted.