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());
}
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]);
    long long an = ((int)(fac[AA[0]]).size()) * ((int)(fac[AA[1]]).size()) *
                   ((int)(fac[AA[2]]).size());
    int ker = 0;
    {
      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]++;
        }
      }
      an += cnt * (cnt - 1LL);
      an += cnt * (cnt - 1LL) * (cnt - 2LL) * 2 / 3;
      ker = cnt;
    }
    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++;
          }
        }
        an -= cnt * (cnt - 1LL) / 2 * ((int)(fac[AA[3 - i - j]]).size());
        an += (cnt - ker) * (cnt * (cnt - 1) / 2);
      }
    W(an);
  }
  return 0;
}
