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>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<deque>
#include<cmath>
#include<set>
#include<cstring>
#include<string.h>
using namespace std;
typedef long long ll;
typedef long double lb;
const int inf = 0x3f3f3f3f;
//----------------
#define int long long
#define double long double
//----------------
#define file(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return x * f;
}
#define rd(x) scanf("%lld", &x)
#define sdf(x) x=read()
#define asd(x) scanf("%Lf",&x)//注意之后的fabsl,sqrtl,输出是.10Lf
#define For(i, a, b) for (int i = a; i <= b; i++)
#define FFor(i, a, b) for (int i = a; i >= b; i--)
#define me(a, b) memset(a, b, sizeof(a))
#define addmod(x, y) (x) = ((x) % mod + (y) % mod) % mod
#define mulmod(x, y) (x) = (((x) % mod) * ((y) % mod)) % mod
#define chkmin(x, y) (x) = (x) <= (y) ? (x) : (y)
#define chkmax(x, y) (x) = (x) >= (y) ? (x) : (y)
#define mid ((l + ((r - l)/2)))
#define Edge struct edge{int to, nx, w;}e[N << 1];int fi[N];int ce = 1;
#define star_link inline void add(int u, int v, int w){e[++ce] = (edge){v, fi[u], w};fi[u] = ce;}
#define Qmul inline ll qmul(ll x,ll y){ll ans=1;for(;y;y>>=1,mulmod(x,x))if(y&1)mulmod(ans,x);return ans;}
#define Go(u) for (int i = fi[u]; ~i; i = e[i].nx)
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
typedef pair<int, int> Pair;
#define cnm cout<<"d"
#define bg1(x) cout<<(#x)<<":"<<x<<" "<<endl
#define bg2(x,y) cout<<(#x)<<":"<<x<<" "<<(#y)<<":"<<y<<" "<<endl
#define bg3(x,y,z) cout<<(#x)<<":"<<x<<" "<<(#y)<<":"<<y<<" "<<(#z)<<":"<<z<<" "<<endl
#define bg4(x,y,z,w) cout<<(#x)<<":"<<x<<" "<<(#y)<<":"<<y<<" "<<(#z)<<":"<<z<<" "<<(#w)<<":"<<w<<" "<<endl
#define lson p << 1, l, mid
#define rson p << 1 | 1, mid + 1, r
#define root 1, 1, n
const double eps = 1e-9;
// srand((unsigned)time(NULL));
ll mod = 998244353;
const int N = 1e6 + 5;

int n;
int a, b, c;
int cnt[N];

int f(int n,int m){
	if(m==1)return n;
	if(m==2&&n>=2)return (n-1)*n/2;
	if(m==3&&n>=3)return (n-2)*(n-1)*n/6;
	return 0;
}
int F1(int x){
	return x*x-f(x,2)-f(x,1);
}
int F2(int x){
	return x*x*x-f(x,3)-f(x,1)*x;
}
signed main()
{
#ifndef ONLINE_JUDGE
	file("test");
#endif
	For(i, 1, 1e5)for (int j = i; j <= 1e5; j += i)cnt[j]++;
	sdf(n);
	int a, b, c;

	while (n--) {
		sdf(a), sdf(b), sdf(c);
		int res = cnt[a] * cnt[b] * cnt[c];
		int g1=cnt[__gcd(a,b)],g2=cnt[__gcd(a,c)],g3=cnt[__gcd(b,c)],g=cnt[__gcd(a,(__gcd(b,c)))];
		if(cnt[a]/g!=1)res-=F1(g3)*(cnt[a]/g);
		if(cnt[b]/g!=1)res-=F1(g2)*(cnt[b]/g);
		if(cnt[c]/g!=1)res-=F1(g1)*(cnt[c]/g);
		res-=F2(g);
		// res-=F1(g1)*(cnt[c]/g)+F1(g2)*(cnt[b]/g)+F1(g3)*(cnt[a]/g)+F2(g);
		printf("%lld\n", res );
	}


}