Codeforces Round 945 (Div. 2) |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

binary search

bitmasks

data structures

greedy

math

two pointers

*1300

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Cat, Fox and the Lonely Array

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputToday, 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 \le k \le n$$$) such that for any two positive integers $$$i$$$ and $$$j$$$ ($$$1 \leq i, j \leq 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

Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 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 \leq n \leq 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 \leq 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

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

Example

Input

71032 2 231 0 253 0 1 4 252 0 4 0 270 0 0 0 1 2 480 1 3 2 2 1 0 3

Output

1 1 3 4 4 7 3

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$$$.

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/24/2024 03:27:18 (l3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|