

The first line of the input contains a single integer 'T', representing the number of test cases.
The first line of each test case contains a string ‘STR’.
For each test case, print a single integer representing the number of palindromes.
Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= |STR| <= 5*10^3
The string ‘STR’ contains small letters only.
Time Limit : 1 sec
The basic idea is to find all the substrings of the string, and for each substring, find whether any anagram of the substring is palindrome or not. The substring is palindrome or not if the frequency of all the characters except at most one character must be even.
Here is the algorithm :
The idea is to generate the masks of 26 characters as there can be a maximum of 26 characters and to count the number of palindromes.
Here is the algorithm :
The idea is similar to approach 2, but we will be using a map to store the frequencies of the masks to avoid another traversing of the string.
Here is the algorithm :