#include <bits/stdc++.h>   using namespace std;   using Long = long long;   constexpr Long MOD = 998244353;   template <typename T>   using V = vector<T>;   template <typename T>   using Vv = V<V<T>>;   using Vb = V<bool>;   using Vvb = V<Vb>;   using Vi = V<int>;   using Vvi = V<Vi>;   using Vl = V<Long>;   using Vvl = V<Vl>;   using Vd = V<double>;   using Vvd = V<Vd>;   using Vs = V<string>;   template <typename First, typename Second>   istream& operator>>(istream& is, pair<First, Second>& v);   template <typename T>   istream& operator>>(istream& is, vector<T>& v) {     for (auto& x : v) {       is >> x;     }     return is;   }   template <typename First, typename Second>   istream& operator>>(istream& is, pair<First, Second>& v) {     is >> v.first >> v.second;     return is;   }   template <typename T>   ostream& operator<<(ostream& os, const vector<T>& v) {     for (const auto& x : v) {       os << x <<    ;     }     return os;   }   void solve() {     Vvi divisors(100001);     for (int d = 1; d <= 100000; ++d) {       for (int k = 1; d * k <= 100000; ++k) {         divisors[d * k].push_back(d);       }     }     int bitcount[] = {0, 1, 1, 2, 1, 2, 2, 3};     int t;     cin >> t;     for (int i = 0; i < t; ++i) {       int num[3];       Vi* d[3];       int n[3];       for (int j = 0; j < 3; ++j) {         cin >> num[j];         d[j] = &divisors[num[j]];         n[j] = d[j]->size();       }       int p[3] = {};       int counts[1 << 3] = {};       while (p[0] < n[0] || p[1] < n[1] || p[2] < n[2]) {         int v[3];         for (int j = 0; j < 3; ++j) {           v[j] = p[j] < n[j] ? (*d[j])[p[j]] : 100001;         }         int m = min({v[0], v[1], v[2]});         int set = 0;         for (int j = 0; j < 3; ++j) {           if (v[j] == m) {             set |= 1 << j;             p[j]++;           }         }         counts[set]++;       }       Long ans = 0;       for (int x = 1; x < (1 << 3); ++x) {         for (int y = x; y < (1 << 3); ++y) {           for (int z = y; z < (1 << 3); ++z) {             if ((x | y | z) == (1 << 3) - 1) {               Long r = 0;               if (x != y && y != z && x != z) {                 ans += (Long)counts[x] * counts[y] * counts[z];               } else if (x == y && y == z) {                 int c = counts[x];                 r = c * (c + 1LL) * (c + 2LL) / (2 * 3);               } else if (x == y) {                 if (bitcount[x] > 1) {                   int c = counts[x];                   r = (c * (c + 1LL) / 2) * counts[z];                 }               } else if (x == z) {                 if (bitcount[x] > 1) {                   int c = counts[x];                   r = (c * (c + 1LL) / 2) * counts[y];                 }               } else if (y == z) {                 if (bitcount[y] > 1) {                   int c = counts[y];                   r = (c * (c + 1LL) / 2) * counts[x];                 }               } else {                 throw exception{};               }               ans += r;             }           }         }       }       cout << ans <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cout.precision(10);     cout << fixed;     solve();     return 0;   }