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.io.IOException;
import java.io.BufferedReader;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.TreeSet;
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;
        MyInput in = new MyInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, MyInput in, PrintWriter out) {
            int t = in.nextInt();
            int[][] f = new int[100000 + 1][];
            TreeSet<Integer> set = new TreeSet<>();
            for (int i = 1; i < f.length; i++) {
                for (int j = 1; j * j <= i; j++) {
                    if (i % j == 0) {
                        set.add(j);
                        if (i != (long) j * j) set.add(i / j);
                    }
                }
                f[i] = new int[set.size()];
                for (int j = 0; j < f[i].length; j++) {
                    f[i][j] = set.pollFirst();
                }
            }

            int[] have = new int[500];
            int[] cnt = new int[8];
            while (t-- > 0) {
                int a = in.nextInt();
                int b = in.nextInt();
                int c = in.nextInt();

                Arrays.fill(cnt, 0);
                int len = 0;
                for (int i = 0, j = 0, k = 0; i < f[a].length || j < f[b].length || k < f[c].length; ) {
                    int val = Integer.MAX_VALUE;
                    if (i < f[a].length && val > f[a][i]) val = f[a][i];
                    if (j < f[b].length && val > f[b][j]) val = f[b][j];
                    if (k < f[c].length && val > f[c][k]) val = f[c][k];
                    have[len] |= i < f[a].length && val == f[a][i] ? 1 : 0;
                    have[len] |= j < f[b].length && val == f[b][j] ? 2 : 0;
                    have[len] |= k < f[c].length && val == f[c][k] ? 4 : 0;
                    cnt[have[len]]++;
                    len++;
                    if (i < f[a].length && val == f[a][i]) i++;
                    if (j < f[b].length && val == f[b][j]) j++;
                    if (k < f[c].length && val == f[c][k]) k++;
                }

                int ans = f[a].length * f[b].length * f[c].length;
                ans -= cnt[7] * (cnt[7] - 1) / 2 * 4;
                ans -= cnt[7] * (cnt[7] - 1) * (cnt[7] - 2) / 6 * 5;
                ans -= cnt[3] * (cnt[3] - 1) / 2;
                ans -= cnt[5] * (cnt[5] - 1) / 2;
                ans -= cnt[6] * (cnt[6] - 1) / 2;
                out.println(ans);
            }
        }

    }

    static class MyInput {
        private final BufferedReader in;
        private static int pos;
        private static int readLen;
        private static final char[] buffer = new char[1024 * 8];
        private static char[] str = new char[500 * 8 * 2];
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];
        private static boolean[] isLineSep = new boolean[256];

        static {
            for (int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
            isLineSep['\r'] = isLineSep['\n'] = true;
        }

        public MyInput(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
        }

        public int read() {
            if (pos >= readLen) {
                pos = 0;
                try {
                    readLen = in.read(buffer);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (readLen <= 0) {
                    throw new MyInput.EndOfFileRuntimeException();
                }
            }
            return buffer[pos++];
        }

        public int nextInt() {
            int len = 0;
            str[len++] = nextChar();
            len = reads(len, isSpace);
            int i = 0;
            int ret = 0;
            if (str[0] == '-') {
                i = 1;
            }
            for (; i < len; i++) ret = ret * 10 + str[i] - '0';
            if (str[0] == '-') {
                ret = -ret;
            }
            return ret;
        }

        public char nextChar() {
            while (true) {
                final int c = read();
                if (!isSpace[c]) {
                    return (char) c;
                }
            }
        }

        int reads(int len, boolean[] accept) {
            try {
                while (true) {
                    final int c = read();
                    if (accept[c]) {
                        break;
                    }
                    if (str.length == len) {
                        char[] rep = new char[str.length * 3 / 2];
                        System.arraycopy(str, 0, rep, 0, str.length);
                        str = rep;
                    }
                    str[len++] = (char) c;
                }
            } catch (MyInput.EndOfFileRuntimeException e) {
            }
            return len;
        }

        static class EndOfFileRuntimeException extends RuntimeException {
        }

    }
}

