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). 

/**
 * Date: 13 Jul, 2018
 * Link:
 *
 * @author Prasad-Chaudhari
 * @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
 * @git: https://github.com/Prasad-Chaudhari
 */
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class newProgram6 {

    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        FastIO in = new FastIO();
        boolean[] cc = new boolean[100001];
        ArrayList<TreeSet<Integer>> lll = new ArrayList<>();
        for (int i = 0; i <= 100000; i++) {
            lll.add(new TreeSet<>());
        }
        for (int i = 2; i <= 1000; i++) {
            if (!cc[i]) {
                lll.get(i).add(i);
                for (int j = i * i; j <= 100000; j = j + i) {
                    cc[j] = true;
                    lll.get(j).add(i);
                    lll.get(j).add(j / i);
                }
            }
        }
        int max = -1;
        lll.get(1).add(1);
        for (int i = 2; i <= 100000; i++) {
            int temp = i;
            TreeSet<Integer> ts = new TreeSet<>();
            ts.add(1);
            for (int j : lll.get(i)) {
                TreeSet<Integer> ts2 = new TreeSet<>();
                int count = 0;
                while (temp % j == 0 && temp != 1 && temp != 0) {
                    temp = temp / j;
                    count++;
                }
                int p = j;
//                System.out.println(i + " " + j + " " + count);
                for (int k = 0; k < count; k++) {
                    for (int l : ts) {
//                        System.out.println(l + " " + l * p);
                        ts2.add(l * p);
                    }
                    p *= j;
                }
                ts.addAll(ts2);
            }
            lll.set(i, ts);
            if (max < ts.size()) {
                max = ts.size();
                System.out.println("max:" + i + " " + max);
            }
//            System.out.println(ts);
        }
//        System.out.println(max);
        int t = in.ni();
        int ff[] = new int[3];
        while (t-- > 0) {
            Set<Long> as = new HashSet<>();
            for (int i = 0; i < 3; i++) {
                ff[i] = in.ni();
            }
            Arrays.sort(ff);
            int a = ff[0];
            int b = ff[1];
            int c = ff[2];
            for (int i : lll.get(a)) {
                for (int j : lll.get(b)) {
                    for (int k : lll.get(c)) {
                        if (i <= j && j <= k) {
                            as.add(i + 100000 * j + 10000000000l * k);
                        }
                    }
                }
            }
            System.out.println(as.size());
        }
    }

    static class FastIO {

        private final BufferedReader br;
        private final BufferedWriter bw;
        private String s[];
        private int index;
        private StringBuilder sb;

        public FastIO() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
            bw = new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8"));
            s = br.readLine().split(" ");
            sb = new StringBuilder();
            index = 0;
        }

        public int ni() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public double nd() throws IOException {
            return Double.parseDouble(nextToken());
        }

        public long nl() throws IOException {
            return Long.parseLong(nextToken());
        }

        public String next() throws IOException {
            return nextToken();
        }

        public String nli() throws IOException {
            try {
                return br.readLine();
            } catch (IOException ex) {

            }
            return null;
        }

        public int[] gia(int n) throws IOException {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public int[] gia(int n, int start, int end) throws IOException {
            validate(n, start, end);
            int a[] = new int[n];
            for (int i = start; i < end; i++) {
                a[i] = ni();
            }
            return a;
        }

        public double[] gda(int n) throws IOException {
            double a[] = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }

        public double[] gda(int n, int start, int end) throws IOException {
            validate(n, start, end);
            double a[] = new double[n];
            for (int i = start; i < end; i++) {
                a[i] = nd();
            }
            return a;
        }

        public long[] gla(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public long[] gla(int n, int start, int end) throws IOException {
            validate(n, start, end);
            long a[] = new long[n];
            for (int i = start; i < end; i++) {
                a[i] = ni();
            }
            return a;
        }

        public int[][] gg(int n, int m) throws IOException {
            int adja[][] = new int[n + 1][];
            int from[] = new int[m];
            int to[] = new int[m];
            int count[] = new int[n + 1];
            for (int i = 0; i < m; i++) {
                from[i] = ni();
                to[i] = ni();
                count[from[i]]++;
                count[to[i]]++;
            }
            for (int i = 0; i <= n; i++) {
                adja[i] = new int[count[i]];
            }
            for (int i = 0; i < m; i++) {
                adja[from[i]][--count[from[i]]] = to[i];
                adja[to[i]][--count[to[i]]] = from[i];
            }
            return adja;
        }

        public void print(String s) throws IOException {
            if (sb.length() > 1000) {
                bw.write(sb.toString());
                bw.flush();
                sb = new StringBuilder();
            } else {
                sb.append(s);
            }
        }

        public void println(String s) throws IOException {
            if (sb.length() > 1000) {
                bw.write(sb.toString());
                bw.newLine();
                bw.flush();
                sb = new StringBuilder();
            } else {
                sb.append(s);
            }
        }

        private String nextToken() throws IndexOutOfBoundsException, IOException {
            if (index == s.length) {
                s = br.readLine().split(" ");
                index = 0;
            }
            return s[index++];
        }

        private void validate(int n, int start, int end) {
            if (start < 0 || end >= n) {
                throw new IllegalArgumentException();
            }
        }
    }
}
