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). 
from random import randint
from itertools import product


def fast_pow(x, y, mod):
    elems = []
    while y:
        elems.append(y % 2)
        y >>= 1
    el = len(elems)
    x_pows = [x for _ in xrange(el)]
    for i in xrange(1, el):
        x_pows[i] = (x_pows[i - 1] * x_pows[i - 1]) % mod

    ret = 1
    for i in xrange(el):
        if elems[i] == 1:
            ret = (ret * elems[i] * x_pows[i]) % mod
    return ret


def miller_rabin_test(n, precision=10):
    assert type(n) == type(1)
    if n == 1:
        return False
    if n % 2 == 0:
        return n == 2
    if n in (3,5,7):
        return True

    s = 0
    n1 = n - 1
    while n1 % 2 == 0:
        s += 1
        n1 /= 2
    d = n1

    while precision > 0:
        precision -= 1
        a = randint(2, n - 2)
        x = fast_pow(a, d, n)
        if x in (1, n - 1):
            continue
        a_good = False
        for _ in xrange(s - 1):
            x = (x * x) % n
            if x == 1:
                return False
            elif x == n - 1:
                a_good = True
                break
        if not a_good:
            return False
    return True


def get_divisors(num):
    if num == 1:
        return [(2, 0)]

    ret = []
    for prime in primes:
        count = 0
        while num % prime == 0:
            count += 1
            num /= prime

        if count != 0:
            ret.append((prime, count))

        if num == 1:
            break

    return ret


def rec_calc(coll, ret, curr, level):
    divisors = coll[level]
    exps = [d[1] for d in divisors]
    bases = [d[0] for d in divisors]
    l = len(divisors)
    for powers in product(*[range(exp + 1) for exp in exps]):
        num = 0
        for i in xrange(l):
            num += bases[i] ** powers[i]
        if level == 2:
            ret.add(tuple(sorted(curr + [num])))
        else:
            curr.append(num)
            rec_calc(coll, ret, curr, level + 1)
            curr.pop()


primes = [num for num in xrange(2, 10 ** 3 + 1) if miller_rabin_test(num)]

n = int(raw_input().strip())

for _ in xrange(n):
    nums = map(int, raw_input().strip().split())

    coll = []
    for num in nums:
        coll.append(get_divisors(num))

    ret = set()
    rec_calc(coll, ret, [], 0)
    print len(ret)
