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.*;
import java.math.*;
import java.lang.*;
 
import static java.lang.Math.*;

public class Main implements Runnable {
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream) {
            this.stream = stream;
        }
        
        public int read() {
            if (numChars==-1) 
                throw new InputMismatchException();
            
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                
                if(numChars <= 0)               
                    return -1;
            }
            return buf[curChar++];
        }
     
        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();
            
            while(isSpaceChar(c)) 
                c = read();
            
            int sgn = 1;
            
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            
            int res = 0;
            do {
                if(c<'0'||c>'9') 
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c)); 
            
            return res * sgn;
        }
        
        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }
        
        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        
        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } 
            while (!isSpaceChar(c));
            
            return res.toString();
        }
     
        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
     
        public String next() {
            return readString();
        }
        
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String args[]) throws Exception {
        new Thread(null, new Main(),"Main",1<<26).start();
    }

    public void run() {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);

        int t = sc.nextInt();

        HashSet<Integer> pd[] = new HashSet[100001];
        for(int i = 1; i <= 100000; ++i)
            pd[i] = new HashSet<>();
        for(int i = 1; i <= 100000; ++i) {
            for(int j = i; j <= 100000; j += i)
                pd[j].add(i);
        }

        for(int x = 0; x < t; ++x) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();

            HashMap<Integer, Integer> map = new HashMap<>();
            for(int i : pd[a]) {
                if(map.get(i) == null)
                    map.put(i, 1);
                else
                    map.put(i, map.get(i) + 1);
            }
            for(int i : pd[b]) {
                if(map.get(i) == null)
                    map.put(i, 1);
                else
                    map.put(i, map.get(i) + 1);
            }
            for(int i : pd[c]) {
                if(map.get(i) == null)
                    map.put(i, 1);
                else
                    map.put(i, map.get(i) + 1);
            }

            int ans = pd[a].size() * pd[b].size() * pd[c].size();
            HashSet<Integer> cnt2 = new HashSet<>();
            HashSet<Integer> cnt3 = new HashSet<>();
            int cnt1 = 0;
            for(int i : map.keySet()) {
                if(map.get(i) == 2)
                    cnt2.add(i);
                else if(map.get(i) == 3)
                    cnt3.add(i);
                else
                    cnt1++;
            }
            int rem1 = 0, rem2 = 0, rem3 = 0, cur = 0;
            for(int i : cnt2) {
                if(pd[a].contains(i) && pd[b].contains(i))
                    cur++;
            }
            rem1 += cur * (cur - 1) / 2 * pd[c].size();
            rem2 += cur * cnt3.size() * pd[c].size();
            rem3 += 3 * cur * cnt3.size() * (cnt3.size() - 1) / 2;
            cur = 0;
            for(int i : cnt2) {
                if(pd[a].contains(i) && pd[c].contains(i))
                    cur++;
            }
            rem1 += cur * (cur - 1) / 2 * pd[b].size();
            rem2 += cur * cnt3.size() * pd[b].size();
            rem3 += 3 * cur * cnt3.size() * (cnt3.size() - 1) / 2;
            cur = 0;
            for(int i : cnt2) {
                if(pd[b].contains(i) && pd[c].contains(i))
                    cur++;
            }
            rem1 += cur * (cur - 1) / 2 * pd[a].size();
            rem2 += cur * cnt3.size() * pd[a].size();
            rem3 += 3 * cur * cnt3.size() * (cnt3.size() - 1) / 2;

            rem3 += cnt3.size() * (cnt3.size() - 1) / 2 * cnt1;

            rem3 += 5 * cnt3.size() * (cnt3.size() - 1) * (cnt3.size() - 2) / 6;

            int rem4 = 2 * cnt3.size() * (cnt3.size() - 1);

            ans -= rem1 + rem2 + rem3 + rem4;

            w.println(ans);
        } 

        w.close();      
    }
}