lh8k is a person who enjoys scavenging. One day, he discovered a typewriter. This typewriter has a button and two paper slots. After some experimentation, he figured out how this typewriter works.
For example, if lh8k inserts a string $$$T=\mathtt{abcd}$$$ into the upper slot and presses the button $$$20$$$ times, he will obtain a printed paper in the lower slot with the string $$$S=\mathtt{abcdcbabcdcbabcdcbab}$$$. Furthermore, if $$$|T|=1$$$, the printed $$$S$$$ will consist of only one character, i.e., $$$S$$$ consists of $$$T[1]$$$ repeated several times.
lh8k now wants to print a string $$$S$$$ using this typewriter, and he wants the length of $$$T$$$ to be as short as possible. He wants to know what the minimum possible length of $$$T$$$ can be. Note that the paper cannot be changed from the start to the end of the printing process, nor can the positions of the paper or pointers be changed arbitrarily. Printing $$$S$$$ must start from the beginning of $$$T$$$ in a forward direction.
However, for this problem, lh8k feels that just finding one answer is not enough, so he wants to find the shortest length of $$$T$$$ for each prefix $$$S'$$$ of the string $$$S$$$.
Due to the overall length of the strings being too long, for each string, you only need to output the value of $$$\bigoplus_{i=1}^{|S|} i \times ans_i$$$, where $$$ans_i$$$ represents the shortest length of $$$T$$$ corresponding to the prefix of length $$$i$$$, and $$$\bigoplus$$$ denotes the bitwise XOR operation.
$$$^{\text{∗}}$$$Actually, it is the paper that moves.
The first line contains an integer $$$t$$$ ($$$1\le t\le 10^3$$$), indicating the number of test cases.
For each test case, there is one line containing a string $$$S$$$ composed only of lowercase English letters ($$$1\le |S|\le 10^6$$$), representing the string that lh8k wants to print using the typewriter.
The data guarantees that $$$\sum|S|\le10^6$$$.
For each test case, output a single integer on a new line, representing the value of $$$\bigoplus_{i=1}^{|S|} i \times ans_i$$$, where the meaning of $$$ans_i$$$ is as described in the problem statement.
5aaaababaabcdcbabcdcbabcdcbabpopipopi
1 3 1 92 51
| Название |
|---|


