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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyBufferedReader in = new MyBufferedReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, MyBufferedReader in, PrintWriter out) {
            int MAX = 100000 + 10;
            ArrayList<ArrayList<Integer>> divisors = new ArrayList<>();
            for (int i = 0; i < MAX; i++) {
                divisors.add(new ArrayList<>());
                divisors.get(i).add(1);
            }


            for (int i = 2; i < MAX; i++) {
                for (int j = i; j < MAX; j += i) {
                    divisors.get(j).add(i);
                }
            }


            int t = in.getAnInt();
            for (int i = 0; i < t; i++) {
                long res = 0;
                int[] a = in.getALineOfInts(3);
                Arrays.sort(a);
                ArrayList<Integer> divs1 = divisors.get(a[0]);
                ArrayList<Integer> divs2 = divisors.get(a[1]);
                ArrayList<Integer> divs3 = divisors.get(a[2]);

                int idxIn1 = 0;
                while (idxIn1 < divs1.size()) {
                    int divFrom1 = divs1.get(idxIn1);
                    int idxIn2 = Collections.binarySearch(divs2, divFrom1);
                    if (idxIn2 < 0) {
                        idxIn2 = -(idxIn2 + 1);
                    }

                    if (idxIn2 >= divs2.size()) {
                        break;
                    }

                    while (idxIn2 < divs2.size()) {
                        int divFrom2 = divs2.get(idxIn2);
                        int idxIn3 = Collections.binarySearch(divs3, divFrom2);
                        if (idxIn3 < 0) {
                            idxIn3 = -(idxIn3 + 1);
                        }

                        if (idxIn3 >= divs3.size()) {
                            break;
                        }

                        res += divs3.size() - idxIn3;
                        idxIn2++;
                    }

                    idxIn1++;
                }

                out.println(res);
            }
        }

    }

    static class MyBufferedReader {
        BufferedReader in;

        public MyBufferedReader(InputStream s) {
            this.in = new BufferedReader(new InputStreamReader(s));
        }

        public MyBufferedReader(BufferedReader in) {
            this.in = in;
        }

        public int getAnInt() {
            int res = -1;
            try {
                res = Integer.parseInt(new StringTokenizer(in.readLine()).nextToken());
            } catch (IOException e) {
                e.printStackTrace();
            }
            return res;
        }

        public int[] getALineOfInts(int numExpected) {
            if (numExpected == 0) {
                try {
                    in.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return new int[0];
            }

            int[] res = new int[numExpected];
            StringTokenizer st = null;
            try {
                st = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < numExpected; i++)
                res[i] = Integer.parseInt(st.nextToken());
            return res;
        }

    }
}

