import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer();
int cases = Integer.parseInt(br.readLine());
for (int i = 0; i < cases; i++) {
StringBuilder str = new StringBuilder(br.readLine());
check(str, sb);
}
System.out.print(sb);
}
static void check(StringBuilder str,StringBuffer sb){
if (str.length() > 2) {
if (str.charAt(0) == 'A') {
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
if(checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)))){
sb.append("FULLY-GROWN\n");
}else{
sb.append("MUTANT\n");
}
}else{
sb.append("MUTANT\n");
}
}else{
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
if(checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)))){
sb.append("FULLY-GROWN\n");
}else{
sb.append("MUTANT\n");
}
}else if(str.charAt(str.length()-1)=='A'){
if(checkNotMutant(new StringBuilder(str.substring(1, str.length()-1)))){
sb.append("MUTAGENIC\n");
}else{
sb.append("MUTANT\n");
}
}else{
sb.append("MUTANT\n");
}
}
}else{
if (str.charAt(0) == 'A') {
if (str.length() == 1) {
sb.append("SIMPLE\n");
} else {
if (str.charAt(1) == 'B') {
sb.append("FULLY-GROWN\n");
} else {
sb.append("MUTANT\n");
}
}
}else{
sb.append("MUTANT\n");
}
}
}
static boolean checkNotMutant(StringBuilder str) {
if (str.length() > 2) {
if (str.charAt(0) == 'A') {
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
return true&&checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)));
}else{
return false;
}
}else{
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
return true&&checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)));
}else if(str.charAt(str.length()-1)=='A'){
return true&&checkNotMutant(new StringBuilder(str.substring(1, str.length()-1)));
}else{
return false;
}
}
}else{
if (str.charAt(0) == 'A') {
if (str.length() == 1) {
return true;
} else {
if (str.charAt(1) == 'B') {
return false;
} else {
return false;
}
}
}else{
return false;
}
}
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer();
int cases = Integer.parseInt(br.readLine());
for (int i = 0; i < cases; i++) {
StringBuilder str = new StringBuilder(br.readLine());
check(str, sb);
}
System.out.print(sb);
}
static void check(StringBuilder str,StringBuffer sb){
if (str.length() > 2) {
if (str.charAt(0) == 'A') {
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
if(checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)))){
sb.append("FULLY-GROWN\n");
}else{
sb.append("MUTANT\n");
}
}else{
sb.append("MUTANT\n");
}
}else{
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
if(checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)))){
sb.append("FULLY-GROWN\n");
}else{
sb.append("MUTANT\n");
}
}else if(str.charAt(str.length()-1)=='A'){
if(checkNotMutant(new StringBuilder(str.substring(1, str.length()-1)))){
sb.append("MUTAGENIC\n");
}else{
sb.append("MUTANT\n");
}
}else{
sb.append("MUTANT\n");
}
}
}else{
if (str.charAt(0) == 'A') {
if (str.length() == 1) {
sb.append("SIMPLE\n");
} else {
if (str.charAt(1) == 'B') {
sb.append("FULLY-GROWN\n");
} else {
sb.append("MUTANT\n");
}
}
}else{
sb.append("MUTANT\n");
}
}
}
static boolean checkNotMutant(StringBuilder str) {
if (str.length() > 2) {
if (str.charAt(0) == 'A') {
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
return true&&checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)));
}else{
return false;
}
}else{
if(str.charAt(str.length()-2)=='A' &&
str.charAt(str.length()-1)=='B'){
return true&&checkNotMutant(new StringBuilder(str.substring(0, str.length()-2)));
}else if(str.charAt(str.length()-1)=='A'){
return true&&checkNotMutant(new StringBuilder(str.substring(1, str.length()-1)));
}else{
return false;
}
}
}else{
if (str.charAt(0) == 'A') {
if (str.length() == 1) {
return true;
} else {
if (str.charAt(1) == 'B') {
return false;
} else {
return false;
}
}
}else{
return false;
}
}
}
}
No comments:
Post a Comment