In a popular computer game, Game of Palindromes also known as GOP there is a city called Palindesh. This city is unique in all possible ways. Like, a citizen of the Palindesh is considered to be luckier than the other citizens if he has a name with higher Lannister Ratio.
Lannister Ratio = (No. of palindromic sub strings) / (No. of total sub strings)
Your task is simple, a string of English alphabets are given. You have to find the Lannister Ratio.
A substring is a contiguous sequence of characters within a string. For instance, “the best of” is a substring of “It was the best of times”. This is not to be confused with subsequence, which is a generalization of substring. For example, “Itwastimes” is a subsequence of “It was the best of times”, but not a substring.
A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam or racecar or the number 10801.
Thus, a palindromic sub string is a sub string which is palindrome.
The first line contains a value n, the number of total test cases followed by n (1 ≤ n ≤ 100) lines each containing a string Si (1 ≤ |S| ≤ 1000) consisting of only small case English alphabets.
Print n lines, each line will be the Lannister Ratio for Si for simplicity print only 3 digit after the decimal point.
3 aa aba d
1.000 0.667 1.000