#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void dump(const vector<int>& a) {
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << ' ';
  }
  cerr << endl;
}
vector<pair<int, int>> factorise(long long m) {
  vector<pair<int, int>> res;
  for (long long i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      int cnt = 0;
      while (m % i == 0) {
        cnt++;
        m /= i;
      }
      res.emplace_back(i, cnt);
    }
  }
  return res;
};
using ll = long long;
ll gcd(ll a, ll b, ll& x, ll& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  ll x1, y1;
  ll d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
bool debug = false;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
const int magic = 3;
const int INF = 1e9;
void solve();
void init();
template <typename T, int N>
void dump(const array<T, N>& a) {
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << ' ';
  }
  cerr << endl;
}
int main(int argc, char** argv) {
  cout.precision(15);
  int t = 1;
  cin >> t;
  init();
  for (int tt = 1; tt <= t; tt++) {
    solve();
  }
  return 0;
}
const int MX = 100500;
vector<int> delim[MX];
int p[MX];
long long troek[MX];
long long dvoek(long long n) { return n * (n + 1) / 2; }
void go(int n) {
  auto& curr = delim[n];
  int pr = p[n];
  if (pr == 0) {
    if (n == 1) {
      curr = {1};
    } else {
      curr = {1, n};
    }
    return;
  }
  int cnt = 0;
  while (n % pr == 0) {
    n /= pr;
    cnt++;
  }
  curr.reserve((cnt + 1) * delim[n].size());
  int mult = 1;
  for (int i = 0; i <= cnt; i++) {
    for (auto div : delim[n]) {
      curr.push_back(mult * div);
    }
    mult *= pr;
  }
  sort(curr.begin(), curr.end());
}
void init() {
  for (int i = 1; i < MX; i++) {
    troek[i] = troek[i - 1] + dvoek(i);
  }
  for (int i = 2; i * i < MX; i++) {
    if (p[i] == 0) {
      for (int j = i; j * i < MX; j++) {
        p[i * j] = i;
      }
    }
  }
  for (int n = 1; n < MX; n++) {
    go(n);
  }
  for (int n = 1; n < MX; n++) {
    delim[n].push_back(int(1e9));
  }
}
int cnt[10];
int cnt2[10];
int sum[10];
int sum2[10];
long long solve_true(int a, int b, int c) {
  vector<decltype(delim[a].cbegin())> x(3);
  x[0] = delim[a].begin();
  x[1] = delim[b].begin();
  x[2] = delim[c].begin();
  memset(cnt, 0, sizeof(cnt));
  while (true) {
    int z = *x[0];
    for (int i = 1; i < 3; i++) {
      z = min(z, *x[i]);
    }
    if (z > MX) {
      break;
    }
    int mask = 0;
    for (int i = 0; i < 3; i++) {
      if (*x[i] == z) {
        mask |= 1 << i;
        x[i]++;
      }
    }
    cnt[mask]++;
  }
  for (int i = 1; i < 8; i++) {
    if (debug) cerr << cnt[i] << ' ';
    cnt2[i] = cnt[i] * cnt[i];
    sum[i] = cnt[i] + sum[i - 1];
    sum2[i] = cnt2[i] + sum2[i - 1];
  }
  if (debug) cerr << endl;
  long long res = troek[cnt[7]];
  res += dvoek(cnt[7]) * sum[6];
  res += cnt[7] * (dvoek(cnt[3]) + dvoek(cnt[5]) + dvoek(cnt[6]));
  res += cnt[7] * (sum[6] * sum[6] - sum2[6]) / 2;
  for (int i = 0; i < 3; i++) {
    int bit = 1 << i;
    res += (cnt[bit | 1] + cnt[bit | 2] + cnt[bit | 4]) * dvoek(cnt[7 - bit]);
  }
  res += cnt[3] * cnt[5] * cnt[6];
  res += (cnt[3] * cnt[5] + cnt[3] * cnt[6] + cnt[5] * cnt[6]) *
         (cnt[1] + cnt[2] + cnt[4]);
  res += (cnt[3] + cnt[5] + cnt[6]) *
         (cnt[1] * cnt[2] + cnt[1] * cnt[4] + cnt[2] * cnt[4]);
  res -= cnt[3] * cnt[1] * cnt[2] + cnt[5] * cnt[1] * cnt[4] +
         cnt[6] * cnt[2] * cnt[4];
  res += cnt[1] * cnt[2] * cnt[4];
  return res;
}
long long slow(int a, int b, int c) {
  set<vector<int>> s;
  for (int x = 1; x <= a; x++) {
    if (a % x) continue;
    for (int y = 1; y <= b; y++) {
      if (b % y) continue;
      for (int z = 1; z <= c; z++) {
        if (c % z) continue;
        vector<int> t = {x, y, z};
        sort(begin(t), end(t));
        s.insert(t);
      }
    }
  }
  return s.size();
}
void stress(int n = 60) {
  debug = false;
  for (int a = 1; a <= n; a++) {
    for (int b = a; b <= n; b++) {
      for (int c = b; c <= n; c++) {
        if (slow(a, b, c) != solve_true(a, b, c)) {
          cerr << a << ' ' << b << " " << c << endl;
          cerr << slow(a, b, c) << ' ' << solve_true(a, b, c) << endl;
        }
      }
    }
  }
}
void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << solve_true(a, b, c) << endl;
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

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). 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void dump(const vector<int>& a) {
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << ' ';
  }
  cerr << endl;
}
vector<pair<int, int>> factorise(long long m) {
  vector<pair<int, int>> res;
  for (long long i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      int cnt = 0;
      while (m % i == 0) {
        cnt++;
        m /= i;
      }
      res.emplace_back(i, cnt);
    }
  }
  return res;
};
using ll = long long;
ll gcd(ll a, ll b, ll& x, ll& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  ll x1, y1;
  ll d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
bool debug = false;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
const int magic = 3;
const int INF = 1e9;
void solve();
void init();
template <typename T, int N>
void dump(const array<T, N>& a) {
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << ' ';
  }
  cerr << endl;
}
int main(int argc, char** argv) {
  cout.precision(15);
  int t = 1;
  cin >> t;
  init();
  for (int tt = 1; tt <= t; tt++) {
    solve();
  }
  return 0;
}
const int MX = 100500;
vector<int> delim[MX];
int p[MX];
long long troek[MX];
long long dvoek(long long n) { return n * (n + 1) / 2; }
void go(int n) {
  auto& curr = delim[n];
  int pr = p[n];
  if (pr == 0) {
    if (n == 1) {
      curr = {1};
    } else {
      curr = {1, n};
    }
    return;
  }
  int cnt = 0;
  while (n % pr == 0) {
    n /= pr;
    cnt++;
  }
  curr.reserve((cnt + 1) * delim[n].size());
  int mult = 1;
  for (int i = 0; i <= cnt; i++) {
    for (auto div : delim[n]) {
      curr.push_back(mult * div);
    }
    mult *= pr;
  }
  sort(curr.begin(), curr.end());
}
void init() {
  for (int i = 1; i < MX; i++) {
    troek[i] = troek[i - 1] + dvoek(i);
  }
  for (int i = 2; i * i < MX; i++) {
    if (p[i] == 0) {
      for (int j = i; j * i < MX; j++) {
        p[i * j] = i;
      }
    }
  }
  for (int n = 1; n < MX; n++) {
    go(n);
  }
  for (int n = 1; n < MX; n++) {
    delim[n].push_back(int(1e9));
  }
}
int cnt[10];
int cnt2[10];
int sum[10];
int sum2[10];
long long solve_true(int a, int b, int c) {
  vector<decltype(delim[a].cbegin())> x(3);
  x[0] = delim[a].begin();
  x[1] = delim[b].begin();
  x[2] = delim[c].begin();
  memset(cnt, 0, sizeof(cnt));
  while (true) {
    int z = *x[0];
    for (int i = 1; i < 3; i++) {
      z = min(z, *x[i]);
    }
    if (z > MX) {
      break;
    }
    int mask = 0;
    for (int i = 0; i < 3; i++) {
      if (*x[i] == z) {
        mask |= 1 << i;
        x[i]++;
      }
    }
    cnt[mask]++;
  }
  for (int i = 1; i < 8; i++) {
    if (debug) cerr << cnt[i] << ' ';
    cnt2[i] = cnt[i] * cnt[i];
    sum[i] = cnt[i] + sum[i - 1];
    sum2[i] = cnt2[i] + sum2[i - 1];
  }
  if (debug) cerr << endl;
  long long res = troek[cnt[7]];
  res += dvoek(cnt[7]) * sum[6];
  res += cnt[7] * (dvoek(cnt[3]) + dvoek(cnt[5]) + dvoek(cnt[6]));
  res += cnt[7] * (sum[6] * sum[6] - sum2[6]) / 2;
  for (int i = 0; i < 3; i++) {
    int bit = 1 << i;
    res += (cnt[bit | 1] + cnt[bit | 2] + cnt[bit | 4]) * dvoek(cnt[7 - bit]);
  }
  res += cnt[3] * cnt[5] * cnt[6];
  res += (cnt[3] * cnt[5] + cnt[3] * cnt[6] + cnt[5] * cnt[6]) *
         (cnt[1] + cnt[2] + cnt[4]);
  res += (cnt[3] + cnt[5] + cnt[6]) *
         (cnt[1] * cnt[2] + cnt[1] * cnt[4] + cnt[2] * cnt[4]);
  res -= cnt[3] * cnt[1] * cnt[2] + cnt[5] * cnt[1] * cnt[4] +
         cnt[6] * cnt[2] * cnt[4];
  res += cnt[1] * cnt[2] * cnt[4];
  return res;
}
long long slow(int a, int b, int c) {
  set<vector<int>> s;
  for (int x = 1; x <= a; x++) {
    if (a % x) continue;
    for (int y = 1; y <= b; y++) {
      if (b % y) continue;
      for (int z = 1; z <= c; z++) {
        if (c % z) continue;
        vector<int> t = {x, y, z};
        sort(begin(t), end(t));
        s.insert(t);
      }
    }
  }
  return s.size();
}
void stress(int n = 60) {
  debug = false;
  for (int a = 1; a <= n; a++) {
    for (int b = a; b <= n; b++) {
      for (int c = b; c <= n; c++) {
        if (slow(a, b, c) != solve_true(a, b, c)) {
          cerr << a << ' ' << b << " " << c << endl;
          cerr << slow(a, b, c) << ' ' << solve_true(a, b, c) << endl;
        }
      }
    }
  }
}
void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << solve_true(a, b, c) << endl;
}

```