

For the given string “deed”, the string is already a palindrome, thus, minimum characters needed to be added are 0.
Similarly, for the given string “aabaaca”, the minimum characters needed are 2 i.e. ‘a’ and ‘c’ which makes the string “acaabaaca”, which is a palindrome.
The first line contains an integer 'T' which denotes the number of test cases or queries to be run. Then, the T test cases follow.
The first and only line of each test case contains the string STR.
For each test case, print the count of minimum characters needed to make the string palindrome.
Output for each test case will be printed 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 <= 100
1 <= N <= 5000
STR contains only lowercase English letters.
Time limit: 1 second
Note: We can easily find LPS array, using Algorithm for LPS(Prefix Function).