You are given a string s consisting of lowercase English letters.
Let us consider a segment \[ℓ,r] such that 2≤ℓ≤r≤∣s∣. Let us define f(ℓ,r) as the length of the longest suffix of substring s\[1,ℓ−1] such that this suffix can be divided into prefixes of substring s\[ℓ,r]. If there are no such suffixes then f(ℓ,r)=0.
Find the sum ∑_ℓ=2∣s∣∑_r=ℓ∣s∣f(ℓ,r).
The first line contains a single integer t (1≤t≤105) --- the number of test cases. Description of test cases follows.
The only line for each test case contains the string s (2≤∣s∣≤2⋅105) consisting of lowercase English letters.
It is guaranteed that the sum of ∣s∣ for all test cases does not exceed 2⋅105.
For each test case, print a single integer --- the answer to the problem.
Let us consider the third test case. In this case, f(2,2)=0, f(2,3)=0, f(2,4)=0, f(2,5)=0, f(3,3)=0, f(3,4)=2, f(3,5)=2, f(4,4)=0, f(4,5)=2, f(5,5)=0. So the answer is 6.