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;
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 long long N = 2e5;
long long inter(set<long long> &a, set<long long> &b) {
  long long cnt = 0;
  for (long long first : a) {
    cnt += b.count(first);
  }
  return cnt;
}
long long inter(set<long long> &a, set<long long> &b, set<long long> &c) {
  long long cnt = 0;
  for (long long first : a) {
    if (b.count(first) && c.count(first)) {
      cnt++;
    }
  }
  return cnt;
}
struct Zip {
  long long value;
  set<long long> types;
  Zip() {}
  Zip(long long _value) { value = _value; }
};
vector<Zip> zip;
set<long long> posible(const set<long long> &a, const set<long long> &b) {
  set<long long> rez;
  for (long long first : a) {
    for (long long second : b) {
      if (first == second) continue;
      rez.insert(0 ^ 1 ^ 2 ^ first ^ second);
    }
  }
  return rez;
}
map<set<long long>, long long> mem1[N];
long long dp1(long long i, set<long long> posible) {
  if (i == ((long long)zip.size())) return 0;
  if (mem1[i].count(posible)) return mem1[i][posible];
  long long norm = 0;
  for (long long type : zip[i].types) {
    if (posible.count(type)) {
      norm = 1;
      break;
    }
  }
  return mem1[i][posible] = norm + dp1(i + 1, posible);
}
map<set<long long>, long long> mem2[N];
long long dp2(long long i, set<long long> types) {
  if (i == ((long long)zip.size())) return 0;
  if (mem2[i].count(types)) return mem2[i][types];
  return mem2[i][types] =
             dp1(i + 1, posible(types, zip[i].types)) + dp2(i + 1, types);
}
map<set<long long>, long long> mem_merge[N];
long long dp2_merge(long long i, set<long long> types) {
  if (i == ((long long)zip.size())) return 0;
  if (mem_merge[i].count(types)) return mem_merge[i][types];
  long long norm = 0;
  for (long long first : zip[i].types) {
    for (long long second : zip[i].types) {
      if (first == second) continue;
      if (types.count(0 ^ 1 ^ 2 ^ first ^ second)) {
        norm = 1;
        break;
      }
    }
  }
  return mem_merge[i][types] = norm + dp2_merge(i + 1, types);
}
long long dp3(long long i) {
  if (i == ((long long)zip.size())) return 0;
  long long rez = dp3(i + 1);
  rez += dp2(i + 1, zip[i].types);
  set<long long> posible;
  for (long long first : zip[i].types) {
    for (long long second : zip[i].types) {
      if (first == second) continue;
      posible.insert(0 ^ 1 ^ 2 ^ first ^ second);
    }
  }
  if (((long long)zip[i].types.size()) == 3) {
    rez++;
  }
  rez += dp1(i + 1, posible);
  rez += dp2_merge(i + 1, zip[i].types);
  return rez;
}
signed main(signed argc, char *argv[]) {
  long long n;
  cin, n;
  vector<vector<long long>> divs(N);
  for (long long i = 1; i < N; i++) {
    for (long long j = i; j < N; j += i) {
      divs[j].push_back(i);
    }
  }
  map<vector<long long>, long long> mem;
  for (long long i = 0; i < (n); i++) {
    vector<long long> v(3);
    cin, v;
    if (mem.count(v)) {
      smart_io::precall_print();
      cout, v;
      continue;
    }
    zip.clear();
    vector<pair<long long, long long>> t;
    for (long long j = 0; j < (3); j++) {
      for (long long first : divs[v[j]]) {
        t.emplace_back(first, j);
      }
    }
    sort(t.begin(), t.end());
    zip.push_back(Zip(t[0].first));
    zip.back().types.insert(t[0].second);
    for (long long j = 1; j < ((long long)t.size()); j++) {
      pair<long long, long long> p = t[j];
      if (zip.back().value == p.first) {
        zip.back().types.insert(p.second);
      } else {
        zip.emplace_back(p.first);
        zip.back().types.insert(p.second);
      }
    }
    for (long long i = 0; i <= ((long long)zip.size()); i++) {
      mem1[i].clear();
      mem2[i].clear();
      mem_merge[i].clear();
    }
    smart_io::precall_print();
    cout, mem[v] = dp3(0);
  }
}
