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.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/7/9 15:33
 * @see format
 */
public class D {

    private static BufferedReader br;
    private static StreamTokenizer st;
    private static PrintWriter pw;

    static int N = 100001;
    static List<Integer>[] appro = new List[N];
    static int C[][] = new int[1001][4];

    private static void c() {
        for (int j = 1; j <= 1000; j++) {
            C[j][0] = 1;
            for (int i = 1; i <= 3 && i <= j; i++) {
                C[j][i] = C[j][i - 1] * (j - i + 1) / i;
            }
        }
    }

    private static void init() {
        c();
        for (int i = 1; i < N; i++) {
            int sqrt = (int) Math.sqrt(i);
            int k = sqrt * 2;
            if (i % sqrt == 0) {
                k--;
            }
            appro[i] = new ArrayList<>(k);
            for (int j = 1; j <= sqrt; j++) {
                if (i % j == 0) {
                    appro[i].add(j);
                    if (j != i / j) {
                        appro[i].add(i / j);
                    }
                }
            }
            appro[i].sort(Comparator.naturalOrder());
        }
    }

    private static int gcd(int a, int b) {
        while (b != 0) {
            int tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }


    private static void solve() throws IOException {
        init();

        int T = nextInt();
        while (T-- > 0) {
            int tri[] = {nextInt(), nextInt(), nextInt()};
            Arrays.sort(tri);
            List<Integer> a = appro[tri[0]];
            List<Integer> b = appro[tri[1]];
            List<Integer> c = appro[tri[2]];

            int ab = gcd(tri[1], tri[0]);
            int bc = gcd(tri[2], tri[1]);
            int ac = gcd(tri[2], tri[0]);
            int abc = gcd(tri[2], ab);

            int nab = appro[ab].size();
            int nbc = appro[bc].size();
            int nac = appro[ac].size();
            int nabc = appro[abc].size();

            int sum = a.size() * b.size() * c.size();
            int fail = 0;
            if (nabc >= 2) {
                fail += (int) (Math.pow(nabc, 3) - (C[nabc][1] + C[nabc][2] * 2 + C[nabc][3]));
            }

            if (nab >= 2) fail += (Math.pow(nab, 2) - (C[nab][1] + C[nab][2])) * (c.size() - (nabc == 1 ? 0 : nab));
            if (nbc >= 2) fail += (Math.pow(nbc, 2) - (C[nbc][1] + C[nbc][2])) * (a.size() - (nabc == 1 ? 0 : nab));
            if (nac >= 2) fail += (Math.pow(nac, 2) - (C[nac][1] + C[nac][2])) * (b.size() - (nabc == 1 ? 0 : nab));

            pw.print(sum - fail);
            if (T > 0) {
                pw.println();
            }
        }
    }

    public static void main(String args[]) throws IOException {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        if (!oj) {
            System.setIn(new FileInputStream("in.txt"));
//            System.setOut(new PrintStream("out.txt"));
        }
        br = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(br);
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        st.ordinaryChar('\''); //指定单引号、双引号和注释符号是普通字符
        st.ordinaryChar('\"');
        st.ordinaryChar('/');

        long t = System.currentTimeMillis();
        solve();
        if (!oj) {
            pw.println("[" + (System.currentTimeMillis() - t) + "ms]");
        }
        pw.flush();
    }

    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    private static long nextLong() throws IOException {
        st.nextToken();
        return (long) st.nval;
    }

    private static double nextDouble() throws IOException {
        st.nextToken();
        return st.nval;
    }

    private static String[] nextSS(String reg) throws IOException {
        return br.readLine().split(reg);
    }

    private static String nextLine() throws IOException {
        return br.readLine();
    }
}
