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). 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second

#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)

#define read1(a) int a; scanf("%d", &a)
#define read2(a,b) int a,b; scanf("%d %d", &a, &b)
#define read3(a,b,c) int a,b,c; scanf("%d %d %d", &a, &b, &c)
#define read(n,arr) int arr[n]; f0r(i,n){ scanf("%d", &arr[i]); }
#define print1(a) printf("%d \n", a)
#define print2(a, b) printf("%d %d \n", a, b)
#define print3(a, b, c) printf("%d %d %d \n", a, b, c)
#define print(v) for (int i : v) { printf("%d ", i); } printf("\n")

#define debug printf("asdf\n");
#define newl printf("\n");
#define usaco(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout);
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
void io(string taskname){
    string fin = taskname + ".in";
    string fout = taskname + ".out";
    const char* FIN = fin.c_str();
    const char* FOUT = fout.c_str();
    freopen(FIN, "r", stdin);
    freopen(FOUT, "w", stdout);
    fast_io();
}
vector<ll> primes;
ll s(ll a){
    vector<ll> times;
    ll fin = 1;
    for(ll i: primes){
        double x = a;
        ll y = 0;
        while(x == floor(x)){
            x = x/i;
            y +=1;
        }
        y -= 1;
        fin = fin*(y+1);
    }
    return fin;
}
ll gcd(ll x, ll y){
    return __gcd(x, y);
}
ll gcd3(ll x, ll y, ll z){
    return __gcd(__gcd(x, y), z);
}
void sieve(ll n)
{

    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p
            for (ll i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (ll p=2; p<=n; p++)
       if (prime[p])
          primes.emplace_back(p);
}
ll c3(ll a){
    if(a<3){
        return 0;
    }
    if(a == 3){
        return 1;
    }
    return a* (a-1)*(a-2)/6;
}
ll c2(ll a){
    if(a<2){
        return 0;
    }
    return a*(a-1)/2;
}
ll f2(ll a){
    return c2(a) + a;
}
int main(){
    int t;
    cin >>t;
    sieve(100005);
    f0r(i, t){
        ll p, q, r;
        cin >> p >> q >> r;
        ll z = gcd(p,q);
        ll x = gcd(q, r);
        ll y = gcd(p, r);
        ll w = gcd3(p, q, r);
        ll e = s(w);
        ll b =  s(z) - e;
        ll f = s(x) - e;
        ll d = s(y) - e;
        ll a = s(p) - b - d- e;
        ll c = s(q) - b - e -f;
        ll g = s(r) -  d - e - f;
        //cout << a << " " << b << " " << c << " " << d << " " << e <<" " << f << " " << g << " morehi" << endl;
        ll one1 = a*b*d + a*b*e + a*b*f+ a*b*g + a*c*d+ a*c*e+a*c*f + a*c*g + a*d*e + a*d*f;
        ll one2 = a*e*f + a*e*g + a*f*g + b*c*d + b*c*e+ b*c*f + b*c*g + b*d*e+ b*d*f+ b*d*g + b*e*f + b*e*g;
        ll one3 = b*f*g + c*d*e +c*d*f +  c*d*g+ c*e*f + c*e*g +d*e*f + d*e*g + d*f*g + e*f*g;
        ll two1 = f2(e) *a + f2(f)*a + f2(b) * d+ f2(b) * e + f2(b)*f+ f2(b)*g;
        ll two2 = b*f2(d) + b*f2(e) + b*f2(f) + c*f2(d) + c*f2(e)  + f2(d) * e + f2(d) *f;
        ll two3 = f2(d) *f + f2(e) * d  + f2(f) *d + f2(e)*f + f2(e)*g+ f2(f)*e;
        ll three1 = c3(e) + e + e*(e-1);
        cout << one1+ one2+ one3 + two1 + two2+ two3 + three1<< endl;
        //cout << one1 + one2 + one3<< " " << two1+ two2 + two3<< " " << three1 << endl;

    }
}
