Submissions will no longer be placed on the leaderboard. You may still attempt this problem for practice.

James found a love letter his friend Harry wrote to his girlfriend. Being a prankster, he decides to make some fun adjustments to it by changing each of its words into palindromes.

To do this, he follows two rules:

  1. He can reduce the value of a letter (e.g.: he can reduce d to c, but can't increment c to d).
  2. A letter can be reduced more than once, but once it is reduced to a it becomes locked at a and its value can no longer be changed.

Each reduction in a letter's value is counted as operation. For each test case, find the minimum number of operations required to convert the given string to a palindrome.

Input Format

The first line contains an integer, (the number of test cases).
Each of the subsequent lines contains a single string of lowercase characters.

Constraints

length of string
All characters are lowercase English letters.

Output Format

For each test case, print a new line with the minimum number (as an integer) of operations required to convert the given string to a palindrome.

Sample Input

4
abc
abcba
abcd
cba

Sample Output

2
0
4
2

Explanation

Test Case 0: abc abb aba. We print the number of operations, , on a new line.

Test Case 1: abcba is already a palindrome. We print the number of operations, , on a new line.

Test Case 2: abcd abcc abcb = abca. Then abca abba. We print the number of operations, , on a new line.

Test Case 3: cba bba aba. We print the number of operations, , on a new line.

Line: 1 Col: 1
  1. Challenge Walkthrough
    Let's walk through this sample challenge and explore the features of the code editor.1 of 6
  2. Review the problem statement
    Each challenge has a problem statement that includes sample inputs and outputs. Some challenges include additional information to help you out.2 of 6
  3. Choose a language
    Select the language you wish to use to solve this challenge.3 of 6
  4. Enter your code
    Code your solution in our custom editor or code in your own environment and upload your solution as a file.4 of 6
  5. Test your code
    You can compile your code and test it for errors and accuracy before submitting.5 of 6
  6. Submit to see results
    When you're ready, submit your solution! Remember, you can go back and refine your code anytime.6 of 6
  1. Check your score