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>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
char string_in_buffer[(int)260];
void fast_scan(int &first) { scanf("%d", &first); }
void fast_scan(long long &first) { scanf("%lld", &first); }
void fast_scan(unsigned long long &first) { scanf("%llu", &first); }
void fast_scan(double &first) { scanf("%lf", &first); }
void fast_scan(long double &first) { scanf("%Lf", &first); }
void fast_scan(char &first) {
  scanf("%c", &first);
  if (first == '\n') {
    fast_scan(first);
  }
}
void fast_scan(string &first) {
  scanf("%s", string_in_buffer);
  first = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
  fast_scan(p.first);
  fast_scan(p.second);
}
template <class T>
void fast_scan(vector<T> &v) {
  for (auto &first : v) fast_scan(first);
}
void fast_print(const int &first) { printf("%d", first); }
void fast_print(const long long &first) { printf("%lld", first); }
void fast_print(const unsigned long long &first) { printf("%llu", first); }
void fast_print(const double &first) { printf("%.15lf", first); }
void fast_print(const long double &first) { printf("%.15Lf", first); }
void fast_print(const char &first) { printf("%c", first); };
void fast_print(const string &first) { printf("%s", first.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
  fast_print(p.first);
  fast_print(' ');
  fast_print(p.second);
}
template <class T>
void fast_print(const vector<T> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print(' ');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const vector<vector<T>> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print('\n');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const T &v) {
  for (const auto &first : v) {
    fast_print(first);
    fast_print(' ');
  }
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
  fast_print(print_start);
  print_start = "\n";
  first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T kek, Args... args) {
  if (!first_print) {
    fast_print("\n");
  } else {
    first_print = false;
  }
  fast_print(names.front());
  fast_print(" = ");
  fast_print(kek);
  names.pop_front();
  _print(names, args...);
}
}  // namespace smart_io
template <class T>
ostream &operator,(ostream &os, const T &object) {
  if (!smart_io::first_print) {
    fast_print(smart_io::sep);
  } else {
    smart_io::first_print = false;
  }
  fast_print(object);
  return os;
}
template <class T>
istream &operator,(istream &is, T &object) {
  fast_scan(object);
  return is;
}
namespace typedefs {}
namespace numbers_operation {
template <class T>
T floor_mod(T a, T b) {
  if (a % b == 0) return 0;
  if (a >= 0 && b >= 0) return a % b;
  if (a <= 0 && b <= 0) return a % b;
  return abs(b) - (abs(a) % abs(b));
}
}  // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
const int N = 2e5;
int inter(set<int> &a, set<int> &b) {
  int cnt = 0;
  for (int first : a) {
    cnt += b.count(first);
  }
  return cnt;
}
int inter(set<int> &a, set<int> &b, set<int> &c) {
  int cnt = 0;
  for (int first : a) {
    if (b.count(first) && c.count(first)) {
      cnt++;
    }
  }
  return cnt;
}
struct Zip {
  int value;
  int types = 0;
  void add(int type) { types = (types | (1 << type)); }
  Zip() {}
  Zip(int _value) { value = _value; }
};
vector<Zip> zip;
int posible(const int &a, const int &b) {
  int rez = 0;
  for (int i = 0; i < (3); i++) {
    if (!((1 << i) & a)) continue;
    for (int j = i + 1; j < 3; j++) {
      if (!((1 << j) & b)) continue;
      rez = (rez | ((1 << (1 ^ 2 ^ i ^ j))));
    }
  }
  return rez;
}
int mem1[N][10];
int dp1(int i, int posible) {
  if (i == ((int)zip.size())) return 0;
  if (mem1[i][posible] != -1) return mem1[i][posible];
  int norm = 0;
  if (posible & zip[i].types) {
    norm = 1;
  }
  return mem1[i][posible] = norm + dp1(i + 1, posible);
}
int mem2[N][10];
int dp2(int i, int types) {
  if (i == ((int)zip.size())) return 0;
  if (mem2[i][types] != -1) return mem2[i][types];
  return mem2[i][types] =
             dp1(i + 1, posible(types, zip[i].types)) + dp2(i + 1, types);
}
int mem_merge[N][10];
int dp2_merge(int i, int types) {
  if (i == ((int)zip.size())) return 0;
  if (mem_merge[i][types] != -1) return mem_merge[i][types];
  int norm = 0;
  if (__builtin_popcount(zip[i].types) >= 2) {
    if ((zip[i].types | types) == 7) {
      norm = 1;
    }
  }
  return mem_merge[i][types] = norm + dp2_merge(i + 1, types);
}
int dp3(int i) {
  if (i == ((int)zip.size())) return 0;
  int rez = dp3(i + 1);
  rez += dp2(i + 1, zip[i].types);
  int posible = 0;
  if (zip[i].types == 7) {
    rez++;
    posible = 7;
  } else if (__builtin_popcount(zip[i].types) == 2) {
    posible = (7 ^ zip[i].types);
  }
  rez += dp1(i + 1, posible);
  rez += dp2_merge(i + 1, zip[i].types);
  return rez;
}
signed main(signed argc, char *argv[]) {
  int n;
  cin, n;
  vector<vector<int>> divs(N);
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N; j += i) {
      divs[j].push_back(i);
    }
  }
  map<vector<int>, int> mem;
  for (int i = 0; i < (n); i++) {
    vector<int> v(3);
    cin, v;
    if (mem.count(v)) {
      smart_io::precall_print();
      cout, mem[v];
      continue;
    }
    zip.clear();
    vector<pair<int, int>> t;
    for (int j = 0; j < (3); j++) {
      for (int first : divs[v[j]]) {
        t.emplace_back(first, j);
      }
    }
    sort(t.begin(), t.end());
    zip.push_back(Zip(t[0].first));
    zip.back().add(t[0].second);
    for (int j = 1; j < ((int)t.size()); j++) {
      pair<int, int> p = t[j];
      if (zip.back().value == p.first) {
        zip.back().add(p.second);
      } else {
        zip.emplace_back(p.first);
        zip.back().add(p.second);
      }
    }
    memset(mem1, -1, sizeof(int) * (((int)zip.size()) + 1) * 100);
    memset(mem2, -1, sizeof(int) * (((int)zip.size()) + 1) * 100);
    memset(mem_merge, -1, sizeof(int) * (((int)zip.size()) + 1) * 100);
    smart_io::precall_print();
    cout, mem[v] = dp3(0);
  }
}
