题目描述
The problem is very simple. For every string given as input, you need to tell us the number of subsequences of it that are palindromes (need not necessarily be distinct). Note that the empty string is not a palindrome.
For example, the palindromic subsequences of "aab" are:
"a", "a", "b", "aa", and the method returns 4.
Input
First line contains the number of test cases T (atmost 20). Each of the next T lines contains a single string whose number of palindromic subsequences are to be printed. The maximum length of any input string is 50.
Output
For each test case, print in a single line, the number of palindromic subsequences of the input string.
Example
Input:
3
aab
dddd
thisisapalindromeemordnilapasisiht
Output:
4
15
814157
输入格式
见题面
输出格式
见题面