You are given a rectangular parallelepiped with sides of positive integer lengths A, B and C. 

Find the number of different groups of three integers (a, b, c) such that 1≤ a≤ b≤ c and parallelepiped A× B× C can be paved with parallelepipeds a× b× c. Note, that all small parallelepipeds have to be rotated in the same direction.

For example, parallelepiped 1× 5× 6 can be divided into parallelepipeds 1× 3× 5, but can not be divided into parallelepipeds 1× 2× 3.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.

Each of the next t lines contains three integers A, B and C (1 ≤ A, B, C ≤ 10^5) — the sizes of the parallelepiped.

Output

For each test case, print the number of different groups of three points that satisfy all given conditions.

Example

Input

4
1 1 1
1 6 1
2 2 2
100 100 100


Output

1
4
4
165

Note

In the first test case, rectangular parallelepiped (1, 1, 1) can be only divided into rectangular parallelepiped with sizes (1, 1, 1).

In the second test case, rectangular parallelepiped (1, 6, 1) can be divided into rectangular parallelepipeds with sizes (1, 1, 1), (1, 1, 2), (1, 1, 3) and (1, 1, 6).

In the third test case, rectangular parallelepiped (2, 2, 2) can be divided into rectangular parallelepipeds with sizes (1, 1, 1), (1, 1, 2), (1, 2, 2) and (2, 2, 2). 
#include <bits/stdc++.h>
using namespace std;
const int INFL = (int)1e9;
const long long int INFLL = (long long int)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
long long int rndf(double x) {
  return (long long int)(x + (x >= 0 ? 0.5 : -0.5));
}
long long int floorsqrt(double x) {
  long long int m = (long long int)sqrt(x);
  return m + (m * m <= (long long int)(x) ? 0 : -1);
}
long long int ceilsqrt(double x) {
  long long int m = (long long int)sqrt(x);
  return m + ((long long int)x <= m * m ? 0 : 1);
}
long long int rnddiv(long long int a, long long int b) {
  return (a / b + (a % b * 2 >= b ? 1 : 0));
}
long long int ceildiv(long long int a, long long int b) {
  return (a / b + (a % b == 0 ? 0 : 1));
}
long long int gcd(long long int m, long long int n) {
  if (n == 0)
    return m;
  else
    return gcd(n, m % n);
}
vector<long long int> divisors(long long int x) {
  vector<long long int> ret;
  for (int i = 1; i <= (int)(x); i++) {
    long long int y = (long long int)i * i;
    if (y >= x) {
      if (y == x) ret.push_back(i);
      break;
    } else {
      if (x % i == 0) {
        ret.push_back(i);
        ret.push_back(x / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}
vector<vector<long long int>> cmp2(const vector<long long int> &a,
                                   const vector<long long int> &b) {
  int i = 0;
  int j = 0;
  vector<vector<long long int>> ret(3);
  while (i < a.size() && j < b.size()) {
    if (a[i] == b[j]) {
      ret[0].push_back(a[i]);
      i++;
      j++;
    } else if (a[i] < b[j]) {
      ret[1].push_back(a[i]);
      i++;
    } else {
      ret[2].push_back(b[j]);
      j++;
    }
  }
  while (i < a.size()) {
    ret[1].push_back(a[i]);
    i++;
  }
  while (j < b.size()) {
    ret[2].push_back(b[j]);
    j++;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int N = (long long int)1e5;
  vector<vector<long long int>> divs(N + 1);
  for (int i = 1; i <= (int)(N); i++) divs[i] = divisors(i);
  int t;
  cin >> t;
  for (int unused = 0; unused < (int)(t); unused++) {
    vector<long long int> a(3);
    for (int i = 0; i < (int)(3); i++) cin >> a[i];
    vector<vector<long long int>> buf0 = cmp2(divs[a[0]], divs[a[1]]);
    vector<vector<long long int>> buf1 = cmp2(buf0[1], divs[a[2]]);
    vector<vector<long long int>> buf2 = cmp2(buf0[2], divs[a[2]]);
    vector<vector<long long int>> buf3 = cmp2(buf0[0], divs[a[2]]);
    vector<vector<long long int>> x = {buf1[1], buf3[1], buf1[0], buf3[0]};
    vector<vector<long long int>> y = {buf2[1], buf3[1], buf2[0], buf3[0]};
    vector<long long int> buf4;
    for (auto p : x[2]) buf4.push_back(p);
    for (auto p : y[2]) buf4.push_back(p);
    for (auto p : x[3]) buf4.push_back(p);
    vector<vector<long long int>> buf5 = cmp2(buf4, divs[a[2]]);
    vector<vector<long long int>> z = {buf5[2], x[2], y[2], x[3]};
    long long int ans = 0;
    for (int i = 0; i < (int)(4); i++) {
      for (int j = 0; j < (int)(4); j++) {
        for (int k = 0; k < (int)(4); k++) {
          int cx = x[i].size();
          int cy = y[j].size();
          int cz = z[k].size();
          if (i == 3 && j == 3 && k == 3) {
            ans += cx * (cy + 1) * (cz + 2) / 6;
          } else if (i == 3 && j == 3) {
            ans += cx * (cy + 1) / 2 * cz;
          } else if (i == 3 && k == 3) {
            ans += cx * (cz + 1) / 2 * cy;
          } else if (j == 3 && k == 3) {
            ans += cy * (cz + 1) / 2 * cx;
          } else if (i == 1 && j == 1) {
            ans += cx * (cy + 1) / 2 * cz;
          } else if (i == 2 && k == 1) {
            ans += cx * (cz + 1) / 2 * cy;
          } else if (j == 2 && k == 2) {
            ans += cy * (cz + 1) / 2 * cx;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
