#include <bits/stdc++.h>   using namespace std;   long long calc2(long long a, long long b, long long c, long long ab,                   long long ac, long long bc, long long abc) {     long long parts[] = {a - ab - ac + abc,                          b - ab - bc + abc,                          c - ac - bc + abc,                          ab - abc,                          ac - abc,                          bc - abc,                          abc};     int masks[3] = {1 + 8 + 16 + 64, 2 + 8 + 32 + 64, 4 + 16 + 32 + 64};     static int mark[64 * 8] = {0};     static int id = 0;     ++id;     long long res = 0;     for (int i = 0; i < 7; ++i)       if ((masks[0] >> i) & 1)         for (int j = 0; j < 7; ++j)           if ((masks[1] >> j) & 1)             for (int k = 0; k < 7; ++k)               if ((masks[2] >> k) & 1) {                 int a1 = min(i, min(j, k));                 int a3 = max(i, max(j, k));                 int a2 = i + j + k - a1 - a3;                 if (mark[64 * a1 + 8 * a2 + a3] == id) continue;                 mark[64 * a1 + 8 * a2 + a3] = id;                 if (i == j && j == k) {                   long long x = parts[i];                   res += +x * (x - 1) * (x - 2) / 6 + x * (x - 1) + x;                 } else if (i == j || j == k || i == k) {                   long long x = parts[i];                   long long y = parts[j];                   if (i == j)                     y = parts[k];                   else if (j == k)                     swap(x, y);                   res += x * (x + 1) / 2 * y;                 } else {                   res += parts[i] * parts[j] * parts[k];                 }               }     return res;   }   int get_common_num(vector<int> &a, vector<int> &b) {     int ia = 0, ib = 0;     int res = 0;     while (ia < a.size() && ib < b.size()) {       if (a[ia] == b[ib]) {         ++res;         ++ia, ++ib;       } else if (a[ia] < b[ib])         ++ia;       else         ++ib;     }     return res;   }   int get_common_num(vector<int> &a, vector<int> &b, vector<int> &c) {     int ia = 0, ib = 0, ic = 0;     int res = 0;     while (ia < a.size() && ib < b.size() && ic < c.size()) {       if (a[ia] == b[ib] && b[ib] == c[ic]) {         ++res;         ++ia, ++ib, ++ic;       } else if (a[ia] <= min(b[ib], c[ic]))         ++ia;       else if (b[ib] <= min(a[ia], c[ic]))         ++ib;       else         ++ic;     }     return res;   }   vector<int> dividers[100111];   int main() {     ios::sync_with_stdio(false);     dividers[1].push_back(1);     vector<int> smallest_fact(100111 + 1, 0);     for (int i = 2; i < 100111; ++i) {       if (!smallest_fact[i]) {         smallest_fact[i] = i;         for (long long j = i * (long long)i; j < 100111; j += i) {           if (!smallest_fact[j]) smallest_fact[j] = i;         }       }       int p = smallest_fact[i];       int x = i;       while (x % p == 0) x /= p;       int y = i;       int pp = p;       dividers[i] = dividers[x];       while (y % p == 0) {         for (int d : dividers[x]) dividers[i].push_back(pp * d);         pp *= p;         y /= p;       }       sort(dividers[i].begin(), dividers[i].end());     }     int t;     cin >> t;     while (t--) {       int a, b, c;       cin >> a >> b >> c;       int x = dividers[a].size();       int y = dividers[b].size();       int z = dividers[c].size();       int xy = get_common_num(dividers[a], dividers[b]);       int xz = get_common_num(dividers[a], dividers[c]);       int yz = get_common_num(dividers[b], dividers[c]);       int xyz = get_common_num(dividers[a], dividers[b], dividers[c]);       long long ans = calc2(x, y, z, xy, xz, yz, xyz);       cout << ans <<   n ;     }     return 0;   }