F. Good Substrings
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

For string $$$s$$$ of lowercase Latin letters, we start with an empty string $$$t$$$ and perform the following operation for each character $$$c$$$ of $$$s$$$ in left-to-right order:

  • If $$$t$$$ is empty, push $$$c$$$ at the back of $$$t$$$.
  • Otherwise if the last character of $$$t$$$ is equal to $$$c$$$, pop it.
  • Otherwise (it is different), push the last character of $$$t$$$ at the back of $$$t$$$.

The string $$$s$$$ is considered good if the corresponding string $$$t$$$ is empty after the above sequence of operations. Given a string $$$s$$$ count the number of good substrings of $$$s$$$.

Input

The first line of the input contains $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

Each test case consists of a single string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^6$$$).

It is guaranteed that the sum of $$$|s|$$$ over all test cases doesn't exceed $$$2 \cdot 10^6$$$.

Output

For each test case, print a single integer — the number of good substrings of $$$s$$$.

Example
Input
5
abbcbabbaa
ppqpqqpqp
zzz
helloosijek
rreeerer
Output
8
4
2
3
4