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;
void _add(int &a, int b) { a = (a + b) % 1000000007; }
void _sub(int &a, int b) { a = (a + 1000000007 - b) % 1000000007; }
void _mul(int &a, int b) { a = (long long)a * b % 1000000007; }
void _max(int &a, int b) { a = max(a, b); }
void _min(int &a, int b) { a = min(a, b); }
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long pw(long long a, long long b) {
  long long res(1);
  while (b) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
long long pwM(long long a, long long b, long long mod) {
  long long res(1);
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
const int infi = 2147483647;
const long long infl = 9223372036854775807ll;
const double PI = 3.14159265358979323846;
int n, m, k, q;
vector<int> d[100010];
vector<int> ds[10], aa, bb, cc;
multiset<pair<pair<int, int>, int> > s;
set<pair<pair<int, int>, int> > vis, ss;
int D[4];
long long cnt[10];
void print(int x) {
  if (x == 1) cout << "A";
  if (x == 2) cout << "B";
  if (x == 3) cout << "C";
  if (x == 4) cout << "AB";
  if (x == 5) cout << "AC";
  if (x == 6) cout << "BC";
  if (x == 7) cout << "ABC";
  putchar(' ');
}
long long calc_3(long long x) {
  long long res(0);
  if (x >= 1) res += x;
  if (x >= 2) res += x * (x - 1);
  if (x >= 3) res += x * (x - 1) * (x - 2) / 6;
  return res;
}
long long calc_2(long long x) {
  long long res(0);
  if (x >= 1) res += x;
  if (x >= 2) res += x * (x - 1) / 2;
  return res;
}
int main() {
  aa.push_back(1);
  aa.push_back(4);
  aa.push_back(5);
  aa.push_back(7);
  bb.push_back(2);
  bb.push_back(4);
  bb.push_back(6);
  bb.push_back(7);
  cc.push_back(3);
  cc.push_back(6);
  cc.push_back(5);
  cc.push_back(7);
  for (auto x : aa)
    for (auto y : bb)
      for (auto z : cc) {
        D[0] = x, D[1] = y, D[2] = z;
        sort(D, D + 3);
        s.insert(make_pair(make_pair(D[0], D[1]), D[2]));
      }
  for (int i = 1, lim = 1e5; i <= lim; ++i) {
    for (int j = 1, lim = sqrt(i); j <= lim; ++j) {
      if (i % j == 0) {
        d[i].push_back(j);
        if (j != i / j) d[i].push_back(i / j);
      }
    }
  }
  int T, A1, B1, C1;
  scanf("%d", &T);
  while (T--) {
    vis.clear();
    memset(cnt, 0, sizeof cnt);
    scanf("%d", &A1), scanf("%d", &B1), scanf("%d", &C1);
    for (int i = 1, lim = 7; i <= lim; ++i) ds[i].clear();
    for (auto x : d[A1]) {
      if (B1 % x == 0 && C1 % x == 0)
        ds[7].push_back(x);
      else if (B1 % x == 0) {
        ds[4].push_back(x);
      } else if (C1 % x == 0)
        ds[5].push_back(x);
      else
        ds[1].push_back(x);
    }
    for (auto x : d[B1]) {
      if (A1 % x == 0 && C1 % x == 0)
        continue;
      else if (C1 % x == 0) {
        ds[6].push_back(x);
      } else if (A1 % x != 0)
        ds[2].push_back(x);
    }
    for (auto x : d[C1]) {
      if (A1 % x != 0 && B1 % x != 0) ds[3].push_back(x);
    }
    for (int i = 1, lim = 7; i <= lim; ++i) cnt[i] = ds[i].size();
    long long ans = d[A1].size();
    ans *= d[B1].size();
    ans *= d[C1].size();
    for (auto x : aa)
      for (auto y : bb)
        for (auto z : cc) {
          D[0] = x, D[1] = y, D[2] = z;
          sort(D, D + 3);
          auto p = make_pair(make_pair(D[0], D[1]), D[2]);
          if (vis.count(p)) continue;
          vis.insert(p);
          m = s.count(p);
          long long tmp = cnt[D[0]] * cnt[D[1]] * cnt[D[2]] * m, tmp1 = tmp / m;
          ans -= tmp;
          if (D[1] == D[0] && D[2] == D[0]) {
            tmp1 = calc_3(cnt[D[0]]);
          } else if (D[1] == D[0]) {
            tmp1 = cnt[D[2]] * calc_2(cnt[D[0]]);
          } else if (D[2] == D[1]) {
            tmp1 = cnt[D[0]] * calc_2(cnt[D[1]]);
          }
          ans += tmp1;
        }
    printf("%I64d", (ans));
    putchar('\n');
  }
  return 0;
}
