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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  write(a);
  puts("");
}
const long long N = 100005;
long long t1, t2, t3;
long long q1[N], q2[N], tong[10], f[N], g[N];
bool c(long long a, long long b, long long c) {
  return (a & 1) && (b & 2) && (c & 4);
}
bool check(long long x, long long y, long long z) {
  return c(x, y, z) || c(x, z, y) || c(y, x, z) || c(y, z, x) || c(z, x, y) ||
         c(z, y, x);
}
signed main() {
  long long T = read();
  for (long long i = 1; i <= 100000; i++) {
    g[i] = (long long)i * (i + 1) / 2;
    f[i] = f[i - 1] + g[i];
  }
  while (T--) {
    long long a = read(), b = read(), c = read();
    long long ans = 0;
    t1 = t2 = t3 = 0;
    memset(tong, 0, sizeof(tong));
    for (long long i = 1; i * i <= a; i++)
      if (a % i == 0) {
        q1[++t1] = i;
        if (i * i != a) q1[++t1] = a / i;
      }
    for (long long i = 1; i * i <= b; i++)
      if (b % i == 0) {
        q2[++t2] = i;
        if (i * i != b) q2[++t2] = b / i;
      }
    for (long long i = 1; i * i <= c; i++)
      if (c % i == 0) {
        t3++;
        if (i * i != c) t3++;
      }
    for (long long i = 1; i <= t1; i++) {
      long long s = 1;
      if (b % q1[i] == 0) s |= 2;
      if (c % q1[i] == 0) s |= 4;
      tong[s]++;
    }
    for (long long i = 1; i <= t2; i++)
      if (a % q2[i]) {
        long long s = 2;
        if (c % q2[i] == 0) s |= 4;
        tong[s]++;
      }
    tong[1] = t1 - tong[3] - tong[5] - tong[7];
    tong[2] = t2 - tong[3] - tong[6] - tong[7];
    tong[4] = t3 - tong[5] - tong[6] - tong[7];
    for (long long i = 1; i < 8; i++) {
      for (long long j = i; j < 8; j++) {
        for (long long k = j; k < 8; k++)
          if (check(i, j, k)) {
            if (i == j && i == k)
              ans += f[tong[i]];
            else if (i == j)
              ans += g[tong[i]] * tong[k];
            else if (i == k)
              ans += g[tong[i]] * tong[j];
            else if (j == k)
              ans += g[tong[j]] * tong[i];
            else
              ans += (long long)tong[i] * tong[j] * tong[k];
          }
      }
    }
    writeln(ans);
  }
}
