← Home
write a go solution for Description:
Today, Cat and Fox found an array a consisting of n non-negative integers.

Define the loneliness of a as the smallest positive integer k (1<=k<=n) such that for any two positive integers i and j (1<=i,j<=n-k+1), the following holds: a_i | a_{i+1} | \ldots | a_{i+k-1} = a_j | a_{j+1} | \ldots | a_{j+k-1}, where x|y denotes the bitwise OR of x and y. In other words, for every k consecutive elements, their bitwise OR should be the same. Note that the loneliness of a is well-defined, because for k=n the condition is satisfied.

Cat and Fox want to know how lonely the array a is. Help them calculate the loneliness of the found array.

Input Format:
Each test consists of multiple test cases. The first line contains a single integer t (1<=t<=10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains one integer n (1<=n<=10^5) — the length of the array a.

The second line of each test case contains n integers a_1,a_2,ldots,a_n (0<=a_i<2^20) — the elements of the array.

It is guaranteed that the sum of n over all test cases doesn't exceed 10^5.

Output Format:
For each test case, print one integer  — the loneliness of the given array.

Note:
In the first example, the loneliness of an array with a single element is always 1, so the answer is 1.

In the second example, the OR of each subarray of length k=1 is 2, so the loneliness of the whole array is 1.

In the seventh example, it's true that (0|1|3)=(1|3|2)=(3|2|2)=(2|2|1)=(2|1|0)=(1|0|3)=3, so the condition is satisfied for k=3. We can verify that the condition is not true for any smaller k, so the answer is indeed 3.. Output only the code with no comments, explanation, or additional text.