"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>
const long long N = 1e6 + 10;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const double eps = 1e-8;
const double pi = acos(-1);
using namespace std;
namespace geo {
long long sgn(double x) {
  if (fabs(x) < eps) return 0;
  if (x < 0)
    return -1;
  else
    return 1;
}
struct point {
  double x, y;
  point() {}
  point(double xx, double yy) {
    x = xx;
    y = yy;
  }
  point operator+(point b) { return point(x + b.x, y + b.y); }
  point operator-(point b) { return point(x - b.x, y - b.y); }
  double operator^(point b) { return x * b.y - y * b.x; }
  double operator*(point b) { return x * b.x + y * b.y; }
  point operator*(double b) { return point(x * b, y * b); }
  double gettan() { return atan2(y, x); }
  void read() { scanf("%lf%lf", &x, &y); }
};
struct line {
  point s, e, l;
  line() {}
  line(point ss, point ee) {
    s = ss;
    e = ee;
    l = e - s;
  }
  void read() {
    s.read(), e.read();
    l = e - s;
  }
  double gettan() { return atan2(e.y - s.y, e.x - s.x); }
};
struct circle {
  point o;
  double r;
  circle() {}
  circle(point oo, double rr) {
    o = oo;
    r = rr;
  }
};
double dis2(point a, point b) { return (b - a) * (b - a); }
double dis(point a, point b) { return sqrt(dis2(a, b)); }
bool onseg(line l, point p) {
  bool x1 = sgn((l.s - p) ^ (l.e - p)) == 0;
  bool x2 = sgn((l.s - p) * (l.e - p)) <= 0;
  return x1 && x2;
}
point spin(point p, double a) {
  return point(p.x * cos(a) - p.y * sin(a), p.y * cos(a) + p.x * sin(a));
}
double len(point a) { return sqrt(a * a); }
point projection(line l, point p) {
  return l.s + l.l * ((l.l * (p - l.s)) / ((l.l) * (l.l)));
}
bool judge(line l1, line l2) {
  point a = l1.s, b = l1.e, c = l2.s, d = l2.e;
  bool x1 = sgn((c - a) ^ l1.l) * sgn((d - a) ^ l1.l) <= 0;
  bool x2 = sgn((a - c) ^ l2.l) * sgn((b - c) ^ l2.l) <= 0;
  return x1 && x2 && max(l1.s.x, l1.e.x) >= min(l2.s.x, l2.e.x) &&
         max(l2.s.x, l2.e.x) >= min(l1.s.x, l1.e.x) &&
         max(l1.s.y, l1.e.y) >= min(l2.s.y, l2.e.y) &&
         max(l2.s.y, l2.e.y) >= min(l1.s.y, l1.e.y);
}
point getcross(line l1, line l2) {
  double s1 = ((l2.s - l1.s) ^ (l2.e - l1.s));
  double s2 = ((l2.e - l1.e) ^ (l2.s - l1.e));
  if (s1 + s2 == 0) return point{inf, inf};
  return l1.s + l1.l * (s1 / (s1 + s2));
}
double dis_pl(point p, line l) {
  point v = p - l.s;
  double ans = (v ^ l.l) / sqrt(l.l * l.l);
  return fabs(ans);
}
double askarea(point d[], long long n) {
  d[n + 1] = d[1];
  double area = 0;
  for (long long i = 1; i <= n; i++) area += (d[i] ^ d[i + 1]);
  area /= 2;
  return fabs(area);
}
long long cmp(line a, line b) {
  double t1 = a.gettan(), t2 = b.gettan();
  if (sgn(t1 - t2) == 0) return (a.l ^ (b.e - a.s)) > 0;
  return t1 < t2;
}
long long onright(line a, line b, line c) {
  point p = getcross(b, c);
  return (a.l ^ (p - a.s)) < 0;
}
void hpi(line li[], long long n) {
  line que[N];
  sort(li + 1, li + n + 1, cmp);
  long long l = 1, r = 1, cnt = 0, i;
  for (i = 1; i < n; i++)
    if (sgn(li[i].gettan() - li[i + 1].gettan())) li[++cnt] = li[i];
  li[++cnt] = li[n];
  for (i = 1; i <= cnt; i++) {
    while (r - l > 1 && onright(li[i], que[r - 1], que[r - 2])) r--;
    while (r - l > 1 && onright(li[i], que[l], que[l + 1])) l++;
    que[r++] = li[i];
  }
  while (r - l > 1 && onright(que[l], que[r - 1], que[r - 2])) r--;
  while (r - l > 1 && onright(que[r - 1], que[l], que[l + 1])) l++;
}
}  // namespace geo
long long a[N], b[40];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, i, j, ans = 0;
    cin >> n;
    memset(b, 0, sizeof(b));
    for (i = 1; i <= n; i++) {
      cin >> a[i];
      for (j = 1; j < 33; j++)
        if ((a[i] >> j) == 0) {
          ans += b[j];
          b[j]++;
          break;
        }
    }
    cout << ans << endl;
  }
  return 0;
}
