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;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const long long &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int SIZE = 100001;
int p[SIZE];
vector<int> fac[SIZE];
void prime_init() {
  for (int i = 1; i < SIZE; i++) {
    for (int j = i; j < SIZE; j += i) fac[j].push_back(i);
  }
}
bool is_prime(int x) { return p[x] == x; }
bool done(int it[], int AA[]) {
  for (int i = 0; i < (3); ++i) {
    if (it[i] >= ((int)(fac[AA[i]]).size())) return 1;
  }
  return 0;
}
int solve(int AA[]) {
  set<tuple<int, int, int>> gg;
  for (int x = (1); x <= (AA[0]); ++x)
    for (int y = (1); y <= (AA[1]); ++y)
      for (int z = (1); z <= (AA[2]); ++z) {
        if (AA[0] % x == 0 && AA[1] % y == 0 && AA[2] % z == 0)
          gg.insert(make_tuple(min({x, y, z}),
                               x + y + z - max({x, y, z}) - min({x, y, z}),
                               max({x, y, z})));
      }
  return ((int)(gg).size());
}
long long an = 0;
int use[8];
int now[3];
void dfs(int x, int st, long long v, int gg[]) {
  if (x == 3) {
    int per[3] = {0, 1, 2};
    do {
      bool fail = 0;
      for (int i = 0; i < (3); ++i) {
        if (!((now[i] >> per[i]) & 1)) fail = 1;
      }
      if (!fail) {
        an += v;
        return;
      }
    } while (next_permutation(per, per + 3));
    return;
  }
  for (int i = (st); i < (8); ++i) {
    if (use[i] >= gg[i]) continue;
    int nxt_v = v;
    nxt_v *= gg[i] - use[i];
    use[i]++;
    now[x] = i;
    nxt_v /= use[i];
    dfs(x + 1, i, nxt_v, gg);
    use[i]--;
  }
}
int main() {
  prime_init();
  int ___T;
  scanf("%d", &___T);
  for (int cs = 1; cs <= ___T; cs++) {
    int AA[3];
    for (int i = 0; i < (3); ++i) R(AA[i]);
    an = 0;
    int gg[8] = {};
    for (int i = 0; i < (3); ++i) gg[1 << i] = ((int)(fac[AA[i]]).size());
    {
      int it[3] = {}, cnt = 0;
      while (!done(it, AA)) {
        int mi = min({fac[AA[0]][it[0]], fac[AA[1]][it[1]], fac[AA[2]][it[2]]});
        if (fac[AA[0]][it[0]] == fac[AA[1]][it[1]] &&
            fac[AA[0]][it[0]] == fac[AA[2]][it[2]]) {
          cnt++;
        }
        for (int i = 0; i < (3); ++i) {
          if (fac[AA[i]][it[i]] == mi) it[i]++;
        }
      }
      gg[7] = cnt;
      for (int i = 0; i < (7); ++i) gg[i] -= gg[7];
    }
    for (int i = 0; i < (3); ++i)
      for (int j = (i + 1); j < (3); ++j) {
        int it_i = 0, it_j = 0;
        int cnt = 0;
        while (it_i < ((int)(fac[AA[i]]).size()) &&
               it_j < ((int)(fac[AA[j]]).size())) {
          if (fac[AA[i]][it_i] == fac[AA[j]][it_j]) {
            cnt++;
            it_i++;
            it_j++;
          } else if (fac[AA[i]][it_i] < fac[AA[j]][it_j]) {
            it_i++;
          } else {
            it_j++;
          }
        }
        int me = (1 << i) | (1 << j);
        gg[me] += cnt;
        gg[1 << i] -= gg[me];
        gg[1 << j] -= gg[me];
      }
    int sum = 0;
    for (int i = (1); i < (8); ++i) sum += gg[i];
    an += gg[7];
    an += gg[7] * (sum - 1);
    an += gg[3] * (gg[4] + gg[5] + gg[6] + gg[7]);
    an += gg[5] * (gg[2] + gg[3] + gg[6] + gg[7]);
    an += gg[6] * (gg[1] + gg[3] + gg[5] + gg[7]);
    dfs(0, 1, 1, gg);
    W(an);
  }
  return 0;
}
