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). 
import java.io.*;
import java.lang.*;
import java.rmi.*;
import java.security.*;
import java.util.*;
import java.math.*;

public class A {

    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tok;

    static boolean hasNext() {
        while (tok == null || !tok.hasMoreTokens())
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return false;
            }
        return true;
    }

    static String next() {
        hasNext();
        return tok.nextToken();
    }

    static String nextLine() {
        try {
            return in.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    static long nextLong() {
        return Long.parseLong(next());
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

    static final int maxn = 100010;

    static int f[] = new int[maxn];

    static void init() {
        for (int i = 1; i < maxn; ++i) {
            for (int j = 1; j * j <= i; ++j) {
                if (i % j == 0) {
                    if (j * j != i) f[i] += 2;
                    else f[i] += 1;
                }
            }
        }
    }

    static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public static void main(String[] args) throws IOException {
        init();
        int T;
        T = nextInt();
        while (T-- != 0) {
            int A, B, C;
            A = nextInt();
            B = nextInt();
            C = nextInt();
            int AB = gcd(A, B);
            int AC = gcd(A, C);
            int BC = gcd(B, C);
            int ABC = gcd(AB, AC);
            int a[] = new int[8];
            a[1] = f[A] - f[AB] - f[AC] + f[ABC];
            a[2] = f[B] - f[AB] - f[BC] + f[ABC];
            a[3] = f[AB] - f[ABC];
            a[4] = f[C] - f[AC] - f[BC] + f[ABC];
            a[5] = f[AC] - f[ABC];
            a[6] = f[BC] - f[ABC];
            a[7] = f[ABC];
            long ans = 0;
            for (int i = 1; i <= 7; ++i) {
                if ((i & 1) != 0) {
                    for (int j = 1; j <= 7; ++j) {
                        if ((j & 2) != 0) {
                            for (int k = 1; k <= 7; ++k) {
                                if ((4 & k) != 0) {
                                    if (i == j && j == k)
                                        ans += (long) (a[i] + 2) * (long) (a[i] + 1) * (long) (a[i]) / 6;
                                    else if (i == j) ans += ((long) (a[i] + 1) * (long) (a[i]) / 2) * a[k];
                                    else if (j == k) ans += ((long) (a[j] + 1) * (long) (a[j]) / 2) * a[i];
                                    else if (i == k) ans += ((long) (a[i] + 1) * (long) (a[i]) / 2) * a[j];
                                    else ans += a[i] * a[j] * a[k];
                                }
                            }
                        }
                    }
                }
            }
            out.println(ans);
        }
        out.flush();
    }
}
