// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while(t--){
long long n, k, mul=1, l=0, c=0;
cin >> n;
long long cnt=0;
vector<long long> v;
for(long long i=0;i<n;i++){
long long x;
cin >> x;
v.push_back(x);
}
map<long long,long long > mpp;
for(auto i:v)
{
long long z=log2(i)+1;
mpp[z]++;
}
for(auto i:mpp){
if(i.second>1)
cnt+=((i.second)*(i.second-1))/2;
}
cout<<cnt<<endl;
}
return 0;
}
109A - Lucky Sum of Digits | 864C - Bus |
626B - Cards | 1221A - 2048 Game |
1374D - Zero Remainder Array | 1567C - Carrying Conundrum |
1029C - Maximal Intersection | 922C - Cave Painting |
811C - Vladik and Memorable Trip | 1589C - Two Arrays |
1510K - King's Task | 126B - Password |
462A - Appleman and Easy Task | 839C - Journey |
622A - Infinite Sequence | 659C - Tanya and Toys |
1266A - Competitive Programmer | 234C - Weather |
1332C - K-Complete Word | 525C - Ilya and Sticks |
1555C - Coin Rows | 1324C - Frog Jumps |
715A - Plus and Square Root | 774D - Lie or Truth |
1186D - Vus the Cossack and Numbers | 505B - Mr Kitayuta's Colorful Graph |
1324D - Pair of Topics | 157B - Trace |
34C - Page Numbers | 279A - Point on Spiral |