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). 
/*
		.......The dark religions are departed & sweet science reigns.......
						----William Blake,Vala(The Four Zoas), 1797
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long int, long long int> pll;
typedef pair<char,char> pcc;
typedef vector<long long int> vli;
typedef priority_queue< pii,std::vector<pii>,greater<pii> > maxheap;

#define pb 				push_back
#define mp 				make_pair
#define ins				insert
#define sz(a)			ll(a.size())
#define rep(i,a,b) 		for(int i=a;i<b;i++)
#define repR(i,a,b) 	for(int i=a;i>=b;i--)
#define check1(x)		cout << x << endl
#define check2(x,y)		cout << x << "=>" << y << endl
#define check3(x,y,z)	cout << x << "=>" << y << "=>" << z << endl
#define F 				first
#define S 				second
#define newline			cout << endl
#define fifo			ios_base::sync_with_stdio(0)
#define cintie			cin.tie(0)
#define couttie			cout.tie(0)


const long long int mod=1e9+7;
const long long int N=1e5+5;

ll f(ll inp)
{
	ll x=1;
	ll op=0;
	double s=inp;
	ll tmp=inp;
	double sqs=sqrt(s);
	while(x<sqs)
	{
		if(tmp%x==0){op+=2;}
		x++;
	}
	if (inp == x*x)op++;
	return op;
}

int main()
{
	fifo;cintie;couttie;
	int t;
	cin >> t;
	while(t--)
	{
		ll A,B,C,res=0;
		cin >> A >> B >> C;
		ll fa,fb,fc,fab,fac,fbc,fabc;
		fa=f(A);
		fb=f(B);
		fc=f(C);
		fab=f(__gcd(A,B));
		fac=f(__gcd(A,C));
		fbc=f(__gcd(B,C));
		fabc=f(__gcd(A,__gcd(B,C)));
		fa-=(fab+fac-fabc);
		fb-=(fab+fbc-fabc);
		fc-=(fbc+fac-fabc);
		fab-=fabc;
		fac-=fabc;
		fbc-=fabc;
		res+=fabc*(fabc-1)*(fabc-2)/6+fabc+fabc*(fabc-1)+(fabc*(fabc+1)/2)*(fa+fb+fc+fab+fac+fbc);
		res+=(fabc*(fa+fb+fc+fab+fac+fbc)*(fa+fb+fc+fab+fac+fbc)-fabc*(fa*fa+fb*fb+fc*fc+fab*fab+fbc*fbc+fac*fac))/2;
		res+=fab*(fab+1)*(fc+fac+fbc+fabc)/2;
		res+=fbc*(fbc+1)*(fa+fac+fab+fabc)/2;
		res+=fac*(fac+1)*(fb+fab+fbc+fabc)/2;
		res+=fab*(fc*(fa+fb+fac+fbc)+fac*(fa+fb+fbc)+fbc*(fa+fb));
		res+=fbc*fa*(fb+fc);
		res+=fa*fb*fc;
		check1(res);
	}
}