Matthew is a wise man and Jesse is his best friend. One day, Jesse gave Matthew an integer sequence A of length n and marked one continuous subsequence B of A privately. Matthew didn't know the sequence B at first, but he can guess out the sequence by conjectures. That is, once he claims some conjecture, Jesse will immediately tell him whether the conjecture is true or not.
Matthew has known the sequence B is an interval selected from the sequence A with equal probability. A wise man is never confused, so Matthew will minimize the expected number of conjectures he needs to figure out the sequence B. Could you please determine that expected value? Your answer should be an irreducible fraction p / q, which means p and q are coprime.
The first line contains one integer T, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains one integer n.
The second line contains n space-separated integers A1, A2, ..., An.
1 ≤ T ≤ 1000, 1 ≤ n ≤ 106, 0 ≤ Ai < 100 (i = 1, 2, ..., n).
It is guaranteed that the sum of n in all test cases does not exceed 107 and the size of the standard input file does not exceed 24 MiB.
For each test case, print in one line the answer as an irreducible fraction p / q if q ≠ 1 or a simple p otherwise.
Here is one possible best solution for the second sample. Claim Conjecture 1 firstly and others consequently following the instructions.
## Input
The first line contains one integer T, indicating the number of test cases.The following lines describe all the test cases. For each test case:The first line contains one integer n.The second line contains n space-separated integers A1, A2, ..., An.1 ≤ T ≤ 1000, 1 ≤ n ≤ 106, 0 ≤ Ai < 100 (i = 1, 2, ..., n).It is guaranteed that the sum of n in all test cases does not exceed 107 and the size of the standard input file does not exceed 24 MiB.
## Output
For each test case, print in one line the answer as an irreducible fraction p / q if q ≠ 1 or a simple p otherwise.
[samples]
## Note
Here is one possible best solution for the second sample. Claim Conjecture 1 firstly and others consequently following the instructions. Conjecture 1: The number of 1 in B is odd. If true, go to Conjecture 2, else go to Conjecture 3. Conjecture 2: The length of B is 1. If true, B is [1], else go to Conjecture 4. Conjecture 3: The first element of B is 1. If true, go to Conjecture 5, else go to Conjecture 6. Conjecture 4: The length of B is 4. If true, B is [1, 2, 1, 1], else go to Conjecture 7. Conjecture 5: The length of B is 3. If true, B is [1, 2, 1], else B is [1, 1]. Conjecture 6: The length of B is 1. If true, B is [2], else B is [2, 1, 1]. Conjecture 7: The first element of B is 1. If true, B is [1, 2], else B is [2, 1].
**Definitions**
Let $ A = (a_1, a_2, \dots, a_n) $ be a sequence of integers.
Let $ \mathcal{B} $ be the set of all contiguous subsequences (intervals) of $ A $, i.e.,
$$
\mathcal{B} = \{ A[i:j] \mid 1 \leq i \leq j \leq n \}, \quad \text{where } A[i:j] = (a_i, a_{i+1}, \dots, a_j).
$$
Let $ |\mathcal{B}| = \binom{n+1}{2} = \frac{n(n+1)}{2} $.
Each element of $ \mathcal{B} $ is selected uniformly at random as the hidden subsequence $ B $.
A *conjecture* is a claim of the form "Is $ B = A[i:j] $?" for some $ i \leq j $.
Matthew uses an optimal adaptive strategy to identify $ B $ with minimal expected number of conjectures.
**Constraints**
1. $ 1 \leq T \leq 1000 $
2. $ 1 \leq n \leq 10^6 $
3. $ 0 \leq a_i < 100 $ for all $ i $
4. Total sum of $ n $ across test cases $ \leq 10^7 $
**Objective**
Compute the minimal expected number of conjectures required to identify $ B $, under an optimal strategy, over the uniform distribution over $ \mathcal{B} $.
Output the result as an irreducible fraction $ \frac{p}{q} $, or $ p $ if $ q = 1 $.
**Key Insight**
The problem reduces to computing the **expected depth of a leaf in the optimal binary identification tree** for the set $ \mathcal{B} $, where each leaf corresponds to a unique contiguous subsequence, and internal nodes correspond to queries that partition the set of candidates.
By information theory and optimality of Huffman coding for uniform distributions over distinct items, the minimal expected number of queries equals the **average depth** of a leaf in a **complete binary tree** with $ |\mathcal{B}| $ leaves — **only if all subsequences are distinct**.
But: **Subsequences may not be distinct**. Two different intervals $ A[i:j] $ and $ A[k:\ell] $ may be identical as sequences.
Thus, we must group identical subsequences: let $ \mathcal{S} $ be the set of *distinct* contiguous subsequences of $ A $, and for each $ s \in \mathcal{S} $, let $ f(s) $ be the number of intervals in $ A $ that equal $ s $.
Then the probability of selecting a subsequence equal to $ s $ is $ \frac{f(s)}{\binom{n+1}{2}} $.
The minimal expected number of conjectures is the **entropy of the distribution** over distinct subsequences, **only if** we can design a decision tree that exploits the structure — but in the worst case, without structure, the optimal strategy is to treat each *occurrence* as a distinct outcome? No.
Actually, since Matthew must identify the *exact interval* (not just the content), even if two intervals have the same content, they are different outcomes. So the sample space has $ \binom{n+1}{2} $ equally likely outcomes (each interval is a distinct candidate), regardless of content.
Thus: **Each contiguous subsequence is a distinct hypothesis**, even if content repeats.
Matthew must identify *which interval* was chosen, not just its content.
Therefore, there are $ N = \frac{n(n+1)}{2} $ equally likely hypotheses.
The minimal expected number of yes/no queries to identify one out of $ N $ equally likely items is the **expected depth of a leaf in a balanced binary decision tree**, which is minimized by a Huffman tree — but for uniform distribution, the optimal is a complete binary tree.
The minimal expected number of queries is:
$$
\mathbb{E} = \frac{ \sum_{k=1}^{N} \lceil \log_2 k \rceil }{N}
$$
No — that’s incorrect.
Actually: for $ N $ equally likely items, the minimal expected number of yes/no queries is the **average depth** of the leaves in a **complete binary tree** with $ N $ leaves.
This is a classic problem: the minimal expected number of comparisons to identify one of $ N $ items is:
$$
\mathbb{E} = \frac{ \sum_{i=1}^{N} d_i }{N}
$$
where $ d_i $ is the depth of leaf $ i $ in a **minimum-height binary tree** with $ N $ leaves — which is the same as the **average depth of a leaf in a complete binary tree**.
This value is known to be:
Let $ h = \lfloor \log_2 N \rfloor $, and let $ r = N - 2^h $.
Then:
- $ 2^h - r $ leaves are at depth $ h $
- $ r $ leaves are at depth $ h+1 $
So total sum of depths = $ (2^h - r) \cdot h + r \cdot (h+1) = 2^h h + r $
Thus:
$$
\mathbb{E} = \frac{2^h h + r}{N}, \quad \text{where } h = \lfloor \log_2 N \rfloor, \; r = N - 2^h
$$
**Therefore, the answer for a test case is:**
Let $ N = \frac{n(n+1)}{2} $
Let $ h = \lfloor \log_2 N \rfloor $
Let $ r = N - 2^h $
Let $ \text{sum\_depth} = h \cdot 2^h + r $
Then expected value = $ \frac{\text{sum\_depth}}{N} $
Reduce the fraction $ \frac{\text{sum\_depth}}{N} $ to lowest terms.
**Note**: The values of $ A $ are irrelevant! Because Matthew must identify the *interval*, not the content. Even if two intervals have the same content, they are different outcomes. So the problem reduces to:
> Uniformly random interval among $ \binom{n+1}{2} $, find minimal expected number of yes/no queries to identify it.
Thus, **the sequence $ A $ does not affect the answer**.
**Final Formal Statement**
**Definitions**
Let $ n \in \mathbb{Z}^+ $.
Let $ N = \binom{n+1}{2} = \frac{n(n+1)}{2} $.
Let $ h = \lfloor \log_2 N \rfloor $, $ r = N - 2^h $.
Let $ D = h \cdot 2^h + r $.
**Objective**
Compute the irreducible fraction $ \frac{D}{N} $.
**Constraints**
As given.
**Note**: The sequence $ A $ is irrelevant to the computation.