Philosophical Balance

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

Some power influenced Rikka to stand LCR up. Is it a coincidence that LCR brought her to the middle school attached to the EC Final host?

Rikka is trying to enter the NWPU, but the guard who has been possessed by the devil doesn't let her in. Now she has an idea of forging a pass.

The key is the pass ID, a special string for access-handshaking. The guard has a string ss of length nn as the secret key; when he checks a pass, he chooses a suffix of it (that is, a substring containing the last character), and calculates the length ll of the longest common prefix of the pass ID and the suffix. ll is proportion to the probability to let her pass.

Now Rikka has got the secret key in some secret way. She wants to choose a suffix as the pass ID, too. Since the suffix which the guard will choose is unknown, Rikka would choose her pass ID randomly. That is, Rikka would design a probability distribution for the suffixes (i.e. a series of real numbers p_i,i=1,2,,n\\{p\_i\\}, i = 1, 2, \dots , n, such that p_i0,_i=1np_i=1p\_i \ge 0, \sum\_{i=1}^n p\_i = 1, which means she would choose the suffix of length ii, denoted by s_is\_i, with a probability of p_ip\_i), and maximize the minimum mathematical expectation of ll for any suffix the guard chooses.

Could you please calculate the maximum value of the minimum mathematical expectation of ll? Precisely speaking, what you should calculate is max_p_i(min_j=1n(_k=1np_klcp(s_k,s_j))),\max\_{\\{p\_i\\}} \left(\min\_{j=1}^n\left(\sum\_{k=1}^n p\_k \mathrm{lcp}(s\_k,s\_j)\right)\right), where lcp(s_k,s_j)\mathrm{lcp}(s\_k,s\_j) means the length of longest common prefix of s_ks\_k and s_js\_j.

입력

The first line contains one integer T(1T105)T (1 \leq T \leq 10^5), the number of test cases. Then TT test cases follow.

Each test case contains a string ss of length n(1n2×105)n (1 \leq n \leq 2 \times 10^5), consisting of only lowercase letters, the secret key.

It is guaranteed that the sum of nn in all test cases is at most 5×1055 \times 10^5.

출력

Output TT lines; each line contains a decimal number, the answer to that test case.

Your answer is considered correct if the absolute or relative error doesn't exceed 10910^{-9}.