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\leq a\leq b\leq c$ and parallelepiped $A\times B\times C$ can be paved with parallelepipeds $a\times b\times c$. Note, that all small parallelepipeds have to be rotated in the same direction.

For example, parallelepiped $1\times 5\times 6$ can be divided into parallelepipeds $1\times 3\times 5$, but can not be divided into parallelepipeds $1\times 2\times 3$.
The first line contains a single integer $t$ ($1 \leq t \leq 10^5$) — the number of test cases.

Each of the next $t$ lines contains three integers $A$, $B$ and $C$ ($1 \leq A, B, C \leq 10^5$) — the sizes of the parallelepiped.
4
1 1 1
1 6 1
2 2 2
100 100 100
1
4
4
165
10
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1
1
1
1
1
1
1
1
1
1
10
9 6 8
5 5 2
8 9 2
2 7 9
6 4 10
1 1 8
2 8 1
10 6 3
7 5 2
9 5 4
41
6
21
12
39
4
7
26
8
18
1
100000 100000 100000
8436
#      
import collections
from functools import cmp_to_key
#key=cmp_to_key(lambda x,y: 1 if x not in y else -1 )
import math
import sys
def getIntList():
    return list(map(int, input().split()))    

import bisect 
try :
    import numpy
    dprint = print
    dprint('debug mode')
except ModuleNotFoundError:
    def dprint(*args, **kwargs):
        pass
def makePair(z):
    return  [(z[i], z[i+1]) for i in range(0,len(z),2) ]
def memo(func):  
    cache={}  
    def wrap(*args):  
        if args not in cache:  
            cache[args]=func(*args)  
        return cache[args]  
    return wrap

@memo
def comb (n,k):
    if k==0: return 1
    if n==k: return 1
    return comb(n-1,k-1) + comb(n-1,k)


pre = [[] for _ in range(100000 + 10) ]

for i in range(1, 100010):
    t = i
    while t<=100000:
        pre[t].append(i)
        t+=i
for i in range(1, 100010):
    pre[i] = set(pre[i])
dprint(pre[6])
dprint(pre[1000])
dprint(pre[4300])
dprint('end')
T, = getIntList()

for _ in range(T):
    A,B,C = getIntList()
    zz = [pre[A].copy(), pre[B].copy(), pre[C].copy()]
    
    s0 = pre[A] & pre[B] & pre[C]
    #dprint(A,B,C)
    #dprint(pre[A],pre[B], pre[C])
    #dprint('s0  ',s0)
    zt = [[],[],[]]
    for i in range(3):
        zz[i] -= s0
        
    for i in range(3):
        zt[i].append(s0) 
        now = zz[i].copy()
        for j in range(3):
            if i == j : continue
            ts = zz[i] & zz[j]
            zt[i].append(ts)
            now-=ts
        zt[i].append(now)
    ti = len(s0)
    dprint('zt',zt)
    @memo
    def gauss(x): return (x+1)*x//2
    @memo
    def trigauss(x):
        tot = 0
        for i in range(1,x+1):
            tot+= gauss(i)
        return tot
    
    tot = trigauss(ti)
    dprint(tot)
    for i in range(4):
        for j in range(4):
            for k in range(4):
                if i==0 and j==0 and k ==0:
                    continue
                a = len(zt[0][i])
                b = len(zt[1][j])
                c = len(zt[2][k])
                
                if zt[0][i] == zt[1][j]:
                    tot += gauss(a) *c 
                    continue
                if zt[0][i] == zt[2][k]:
                    tot += gauss(a) *b 
                    continue
                if zt[2][k] == zt[1][j]:
                    tot += gauss(b) *a 
                    continue
                tot+= a*b*c 
    dprint('result')
    print(tot)

