#K801. Maximize Product via Bitwise OR Operations
Maximize Product via Bitwise OR Operations
Maximize Product via Bitwise OR Operations
Alice is playing a game with an array of non-negative integers. She is allowed to perform the following operation any number of times:
- Select any two distinct elements from the array and replace both of them with their bitwise OR.
Her goal is to maximize the product of the array elements. After performing the operations optimally, calculate the product of all the elements in the array modulo \(10^9+7\). Although the operation appears to modify the values, the optimal strategy in these cases turns out to be leaving the array unchanged.
Your task is to compute this maximum product for each test case.
inputFormat
The first line contains an integer \(T\) representing the number of test cases. Each test case begins with an integer \(N\) (the number of elements in the array), followed by \(N\) space-separated non-negative integers.
outputFormat
For each test case, output a single line with the maximum product of the array elements modulo \(10^9+7\).
## sample2
3 2 3 5
4 1 2 4 8
30
64
</p>