#d2959. 子串最大循环次数

子串最大循环次数

Maximum Repetition Count of a Substring

Problem Description

For a given string, if a substring can be formed by repeating some shorter string (the period) kk times (k≥1k\ge 1), we say the repetition count of that substring is kk. Define the repetition count of the whole string as the maximum repetition count over all of its substrings.

For example, in the string psdababab2345 the substring ababab is formed by repeating ab 33 times, so its repetition count is 33.

You are given TT strings; for each, find its repetition count.

Input Format

The first line contains an integer TT (1≤T≤1031\le T\le 10^3), the number of strings.

The next TT lines each contain one string consisting only of uppercase / lowercase letters and digits. The length of each string is less than 5×1035\times 10^3, and ∑∣string∣≤5×103\sum |string|\le 5\times 10^3 is guaranteed.

Output Format

For each test case, output one integer on a single line, the repetition count of that string.

Sample Input

2
psdababab2345
avabcdad

Sample Output

3
1

Sample Explanation

psdababab2345: the substring ababab repeats ab 33 times, so the answer is 33.

avabcdad: there is no substring whose repetition count is greater than 11, so the answer is 11.