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()

@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

for _ in range(T):
    A,B,C = getIntList()
    zz = [pre[A].copy(), pre[B].copy(), pre[C].copy()]
    nall = zz[0] | zz[1] | zz[2]

    gt = collections.Counter()
    for x in nall:
        f = []
        for i in range(3):
            if x in zz[i]:
                f.append(i)
        gt[tuple(f)] +=1
    dprint(gt)

    nk = gt.keys()
    nk = list(nk)
    nk.sort()
    dupc = set()
    tot = 0
    for x0 in nk:
        if 0 not in x0: continue
        for x1 in nk:
            if 1 not in x1: continue
            for x2 in nk:
                if 2 not in x2: continue
                tz = [x0,x1,x2]
                tz.sort()
                tz = tuple(tz)
                if tz in dupc : continue
                dupc.add(tz)
                if x0 == x1 and x1 == x2:
                    tot += trigauss(gt[x0])
                    
                elif x0 == x1:
                    tot += gauss(gt[x0]) * gt[x2]
                elif x0 == x2:
                    tot += gauss(gt[x0]) * gt[x1]
                elif x1 == x2:
                    tot += gauss(gt[x1]) * gt[x0]
                else:
                    tot +=  gt[x0] * gt[x1] * gt[x2] 
                
    print(tot)     

     

