"You must lift the dam. With a lever. I will give it to you.

You must block the canal. With a rock. I will not give the rock to you." 

Danik urgently needs rock and lever! Obviously, the easiest way to get these things is to ask Hermit Lizard for them.

Hermit Lizard agreed to give Danik the lever. But to get a stone, Danik needs to solve the following task.

You are given a positive integer n, and an array a of positive integers. The task is to calculate the number of such pairs (i,j) that i<j and a_i \& a_j ≥ a_i ⊕ a_j, where \& denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND), and ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

Danik has solved this task. But can you solve it?

Input

Each test contains multiple test cases.

The first line contains one positive integer t (1 ≤ t ≤ 10) denoting the number of test cases. Description of the test cases follows.

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

The second line contains n positive integers a_i (1 ≤ a_i ≤ 10^9) — elements of the array.

It is guaranteed that the sum of n over all test cases does not exceed 10^5.

Output

For every test case print one non-negative integer — the answer to the problem.

Example

Input


5
5
1 4 3 7 10
3
1 1 1
4
6 2 5 3
2
2 4
1
1


Output


1
3
2
0
0

Note

In the first test case there is only one pair: (4,7): for it 4 \& 7 = 4, and 4 ⊕ 7 = 3.

In the second test case all pairs are good.

In the third test case there are two pairs: (6,5) and (2,3).

In the fourth test case there are no good pairs.
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
bool compare(pair<int, int> quan1, pair<int, int> quan2) {
  return quan1.second < quan2.second;
}
long long power(long long base, int expo) {
  long long ans = 1;
  while (expo > 0) {
    if (expo % 2 == 1) {
      ans *= base;
    }
    base *= base;
    expo /= 2;
  }
  return ans;
}
long long func(long long arr[], long long n, long long k) {
  int calculate[n][31];
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j <= 30; j++) {
      calculate[i][j] = 0;
    }
  }
  long long answer = 0;
  vector<pair<long long, int>> netvalue;
  long long y = 0;
  for (auto i = 0; i < n; i++) {
    while (arr[i] > 0) {
      calculate[i][y] = arr[i] % 2;
      arr[i] = arr[i] / 2;
      y++;
    }
    reverse(calculate[i], calculate[i] + 31);
    y = 0;
  }
  for (auto j = 0; j <= 30; j++) {
    for (auto i = 1; i < n; i++) {
      calculate[i][j] += calculate[i - 1][j];
    }
  }
  for (auto i = 0; i <= 30; i++) {
    netvalue.push_back(
        make_pair((power(2, (30 - i)) * calculate[n - 1][i]), (30 - i)));
  }
  sort(netvalue.begin(), netvalue.end(), compare);
  long long u = 0;
  while (k > 0) {
    answer += power(2, netvalue[u].second);
    k--;
    u++;
  }
  return answer;
}
void dfSearch(int person, int visited[], unordered_set<int>& settt,
              vector<pair<int, long double>> vec[],
              unordered_map<int, long double> personTotime) {
  visited[person] = 1;
  long double lasttime;
  lasttime = personTotime[person];
  settt.insert(person);
  for (int j = 0; j < vec[person].size(); j++) {
    if ((visited[vec[person][j].first] == 0) &&
        (vec[person][j].second >= lasttime)) {
      personTotime[vec[person][j].first] = vec[person][j].second;
      dfSearch(vec[person][j].first, visited, settt, vec, personTotime);
    }
  }
}
long long lessFindit(long long ele) {
  long long start = 1;
  long long ending = 100000000;
  long long middle;
  long long ans = 0;
  while (start <= ending) {
    middle = (start + ending) / 2;
    if (ele >= ((middle * (middle + 1)) / 2)) {
      start = middle + 1;
      ans = middle;
    } else {
      ending = middle - 1;
    }
  }
  return ans;
}
long long exponentiation(long long num_one, long long num_two, long long mod) {
  long long answer = 1;
  num_one = num_one % mod;
  while (num_two > 0) {
    if (num_two & 1) {
      answer = (answer * num_one) % mod;
    }
    num_two = num_two >> 1;
    num_one = (num_one * num_one) % mod;
  }
  return answer % mod;
}
long long mod_inverse(long long number, long long mod) {
  return exponentiation(number, mod - 2, mod) % mod;
}
long long combi(long long n, long long k, long long mod) {
  if (k == 0) {
    return 1;
  }
  long long factorial[n + 1];
  factorial[0] = 1;
  for (long long i = 1; i <= n; i++) {
    factorial[i] = factorial[i - 1] * i % mod;
  }
  return ((factorial[n] % mod) * mod_inverse(factorial[k], mod) % mod *
          mod_inverse(factorial[n - k], mod) % mod) %
         mod;
}
long long fastModularExpo(long long base, long long expo) {
  long long answer = 1;
  base = base % mod;
  while (expo > 0) {
    if (expo % 2 == 1) {
      answer *= base;
      answer = answer % mod;
    }
    base *= base;
    base = base % mod;
    expo /= 2;
  }
  return (answer % mod);
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
long w;
void fun(vector<pair<long, long>> vec, long n, long max_cost[100][101]) {
  for (long i = 0; i < n; i++) {
    for (long j = 1; j <= w; j++) {
      if (vec[i].second <= j) {
        max_cost[i][j] =
            max(max_cost[i][j], max_cost[i][j - vec[i].second] + vec[i].first);
      } else {
        max_cost[i][j] = max_cost[i - 1][j];
      }
    }
  }
}
long calculate(vector<long> v, long l, long r, long k) {
  v.push_back(l);
  v.push_back(r);
  k = k / 2;
  long sum = 0;
  for (long i = 0; i <= (v.size() - 1 - k); i++) {
    sum += v[i];
  }
  return sum;
}
int main() {
  long t;
  cin >> t;
  while (t--) {
    long n;
    cin >> n;
    long long arr[n];
    int a[n];
    for (long i = 0; i < n; i++) {
      scanf("%lld", &arr[i]);
      a[i] = (int)log2(arr[i]);
    }
    unordered_map<int, long long> m;
    unordered_set<int> s;
    long long ans = 0;
    for (long i = 0; i < n; i++) {
      m[a[i]]++;
      s.insert(a[i]);
    }
    for (auto i : s) {
      ans += (m[i] * (m[i] - 1)) / 2;
    }
    cout << ans << endl;
  }
  return 0;
}
