#Lutece0591. Windy's S(II)

Windy's S(II)

Migrated from Lutece 591 Windy's S(II)

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Given a string AA with length NN.

A0,A1,A2,A3AN1A_0, A_1, A_2, A_3 \cdots A_{N-1}

S(0)=A0,A1,A2,A3AN2,AN1S(0) = A_0, A_1, A_2, A_3 \cdots A_{N-2}, A_{N-1}

S(1)=A1,A2,A3AN2,AN1,A0S(1) = A_1, A_2, A_3 \cdots A_{N-2}, A_{N-1}, A_0

S(2)=A2,A3AN2,AN1,A0,A1S(2) = A_2, A_3 \cdots A_{N-2}, A_{N-1}, A_0, A_1

......

S(N1)=AN1,A0,A1,A2,A3AN2S(N-1) = A_{N-1}, A_0, A_1, A_2, A_3 \cdots A_{N-2}

Windy want to know how many ii in [0,N1][0, N - 1] that make S(i)S(i) euqal to S(0)S(0).

Can you find it for Windy?

Input

The first line of input is the number of test case.

For each test case, there is only one line contains a string AA.

String AA only contains lowercase letter (a--z).

1N10001 \leq N \leq 1000

Output

For each test case output the answer on a single line.

Samples

输入数据 1

3
aaa
abab
aba

输出数据 1

3
2
1

Resources

Sichuan University Programming Contest