SUFEQPRE - Suffix Equal Prefix

no tags 

There is a curious boy in Noapara village, his name is “MODON”.  He wrote a line of small letters only. Now, he want to know how many proper suffix is also prefix of that line. Proper suffix is a suffix of a text whose length is less than the original text. Now you have to help “MODON”. 

Input

Input starts with an integer T (≤ 50), denoting the number of test cases.

Each case contains a string S where 1 ≤ length(S) ≤ 106.

Output

 For each case, print the case number and the answer .

Example

Input:

3
ababab
aaaa
abcabc 

Output: Case 1: 2
Case 2: 3
Case 3: 1

hide comments
aa_09883987: 2023-01-25 05:07:18

WA many times just because of the wrong output's format

punitive_1729: 2021-01-03 16:12:21

Apply Simple Rolling Hash function in O(n)

roro1230: 2019-07-10 16:45:05

1 hit AC. What a wonderful problem ! Using Z algorithm so fit O(n) ><. However the test cases are weak -.-

snsnlcy212: 2018-10-15 03:49:28

hcccccccccccccccccccccccccccccc

amulyagaur: 2018-05-19 07:36:52

Many WA's due to silly mistake! BTW EASY QUESTION WITH ENOUGH TIME LIMIT.

lehienh13: 2017-05-15 16:21:29

bad test, i realized that max length of string is 10^6+7

Last edit: 2017-05-15 16:22:23
abhishek_cic: 2016-07-09 20:07:18

time limit is too strict. please correct the time limit.

aitya: 2016-07-09 19:26:31

time limit is too strict.string questions should pass in o(n) time.had similar problem with another of your question (TULIPNUM) .

Shubham: 2016-06-15 13:17:32

Annoying time limit -_- -_-

ALISHA: 2015-03-11 09:37:42

i think there is problem here. has the time limits been reset.
i have tried submitting the optimal code using fast i/o as well but it shows TLE.
i then copied an ac solution and that also showed TLE . :p
please correct the time limit.


Added by:Raihat Zaman Neloy
Date:2014-10-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem