Harry and String

3.1

14 votes
Algorithms, Easy, Hiring, String Manipulation
Problem

Harry was studying a magic book that categorizes the magic spells into 3 categories - Good , Worst and Bad. If any spell contains all the vowels in alphabetical order then that spell is categorized as Good. If it contains the vowels in reverse alphabetical order , then that spell is categorized as Worst. All the other spells that do not fall in any of the categories before are categorized as Bad. 

Now Harry tries to evaluate himslef by solving a spell categorization exercise at the end of the book , but since he is confused can you help him by solving the problems.

Note: The spell is a word of lower case English alphabets only. If there are no vowels in the string, then the spell is classified as "Good".

Input Format

The first line of input consists of an integer T denoting the number of spells that need to be classified. Each of the next T lines contains a word S.

Output Format

For each string, output the category to which the spell belongs in a new line.

Constraints

1T105
1|S|105 where |S| is the length of spell word.

The sum of length of all the words never exceeds 107.

Sample Input
3
discount
weak
goalkeeper
Sample Output
Good
Worst
Bad
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For case 1, the vowels in the spell are i,o and u and they occur in the alphabetical order in the string, so this is a "Good" string.

For case 2, the vowels in the spell are e and a and they occur in reverse order of the alphabetical order in the string, so this is a "Worst" string.

For case 3, the vowels in the spell are o, a and e and they occur neither in the reverse order nor in the same order as alphabetical, so this is a "Bad" string.

Editor Image

?