The problem rotates around the special F function, defined for 3 integers (a,b,c) as:-
F(a,b,c)= (a|b) & (b|c) & (a&c).
e.g. F(1,2,3)=(1|2) & (2|3) & (1&3)
=3 & 3 & 1
=1
where | is the bitwise "or" , & is bitwise "and" operator.
You have an array a[ ] with n elements , count the total number of distinct possible set of values of (i,j,k)
where i<j<k and such that F(a[i],a[j],a[k]) is non-zero.
Input:-
First-line has t denoting the number of test cases.
Each test case has 2 lines, the first line has n, the number of elements in the array, the second line has n space-separated integers.
Output:-
Print in one line, number of distinct (i,j,k) such that i<j<k and F(a[i],a[j],a[k]) is non-zero for each test case.
Constraints:-
1 <= t <= 10
3 <= n <= 1000
0 <= a[i] <= 100000
Pairs of (i,j,k) , with 0 based indexing are,
First test case:-
(0,1,2)
Second test case:-
(0,1,2) (0,1,3) (0,2,3) (1,2,3)