import java.util.Scanner;
// By nikoo28
class PalindromeIndex {
static boolean isPalindrome
(String str
) {
int n = str.length();
for (int i = 0; i < n / 2; i++)
if (str.charAt(i) != str.charAt(n - i - 1)) return false;
return true;
}
static int palindromeIndex
(String s
) {
int start = 0;
int end = s.length() - 1;
if (isPalindrome(s))
return -1;
while (true) {
if (start > end)
break;
// Code obtained from studyalgorithms.com
// Feel free to copy but please acknowledge wherever possible.
if (s.charAt(start) == s.charAt(end)) {
start++;
end--;
continue;
}
// Create string after removing start
if (isPalindrome(s.substring(0, start) + s.substring(start + 1))) {
return start;
} else if (isPalindrome(s.substring(0, end) + s.substring(end + 1))) {
return end;
} else
return -1;
}
return -1;
}
public static void main
(String[] args
) { Scanner in
= new Scanner
(System.
in); int q = in.nextInt();
for (int a0 = 0; a0 < q; a0++) {
int result = palindromeIndex(s);
}
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKLy8gQnkgbmlrb28yOApjbGFzcyBQYWxpbmRyb21lSW5kZXggewoKICBzdGF0aWMgYm9vbGVhbiBpc1BhbGluZHJvbWUoU3RyaW5nIHN0cikgewoKICAgIGludCBuID0gc3RyLmxlbmd0aCgpOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC8gMjsgaSsrKQogICAgICBpZiAoc3RyLmNoYXJBdChpKSAhPSBzdHIuY2hhckF0KG4gLSBpIC0gMSkpIHJldHVybiBmYWxzZTsKICAgIHJldHVybiB0cnVlOwogIH0KCiAgc3RhdGljIGludCBwYWxpbmRyb21lSW5kZXgoU3RyaW5nIHMpIHsKCiAgICBpbnQgc3RhcnQgPSAwOwogICAgaW50IGVuZCA9IHMubGVuZ3RoKCkgLSAxOwoKICAgIGlmIChpc1BhbGluZHJvbWUocykpCiAgICAgIHJldHVybiAtMTsKCiAgICB3aGlsZSAodHJ1ZSkgewoKICAgICAgaWYgKHN0YXJ0ID4gZW5kKQogICAgICAgIGJyZWFrOwoKCS8vIENvZGUgb2J0YWluZWQgZnJvbSBzdH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