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

// Imports
import java.util.*;
import java.io.*;

public class D5Q {

    public static int countDivisors(int n) 
    { 
        int count = 0;
        
        // Note that this loop runs till square root 
        for (int i = 1; i <= Math.sqrt(n); i++) 
        { 
            if (n%i==0) 
            { 
                // If divisors are equal, print only one 
                if (n/i == i) { 
                    count++;
                }
                else {
                    count += 2;
                }
            } 
        } 
        
        return count;
    } 
    
    static int gcd(int a, int b) {
            while (a != b) {
                
                if(a == 0) {
                    return b;
                }
                if(b == 0) {
                    return a;
                }
            
                if (a > b) {    
                    int floor = a/b;
                    a = a - (b*floor);
                }
                else {
                    int floor = b/a;
                    b = b - (a*floor);     
                }
                
            } 
            return a;
        } 
    
    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException 
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {
        
        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        // BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        
        BufferedReader f = new BufferedReader(new StringReader("4\n" +
"1 1 1\n" +
"1 6 1\n" +
"2 2 2\n" +
"100 100 100"));
        
        int[] factorcache = new int[10001];
        for(int i = 0; i < factorcache.length; i++) {
            factorcache[i] = countDivisors(i);
        }
        
        // TODO code application logic here
        int T = Integer.parseInt(f.readLine());
        for(int z = 0; z < T; z++) {
            StringTokenizer abc = new StringTokenizer(f.readLine());
            
            int a = Integer.parseInt(abc.nextToken());
            int b = Integer.parseInt(abc.nextToken());
            int c = Integer.parseInt(abc.nextToken());
            
            // start with c? if we fix highest divisor
            int gcd_ab = gcd(a, b);
            int gcd_bc = gcd(b, c);
            int gcd_ac = gcd(a, c);
            int gcd_abc = gcd(gcd_ab, c);
            
            // System.out.println(da + " " + db + " " + dc);
            // System.out.println(dab + " " + dbc + " " + dac);
            // System.out.println(dabc);
            
            int[] regions = new int[8];
            
            regions[1] = factorcache[a] - factorcache[gcd_ab] - factorcache[gcd_ac] + factorcache[gcd_abc];
            regions[2] = factorcache[b] - factorcache[gcd_ab] - factorcache[gcd_bc] + factorcache[gcd_abc];
            regions[3] = factorcache[gcd_ab] - factorcache[gcd_abc];
            regions[4] = factorcache[c] - factorcache[gcd_ac] - factorcache[gcd_bc] + factorcache[gcd_abc];
            regions[5] = factorcache[gcd_ac] - factorcache[gcd_abc];
            regions[6] = factorcache[gcd_bc] - factorcache[gcd_abc];
            regions[7] = factorcache[gcd_abc];
            
            long total = 0;
            for (int i = 1; i <= 7; ++i) {
                for (int j = i; j <= 7; ++j) {
                    for (int k = j; k <= 7; ++k) {
                        if (((i | j) | k) == 7
                                && ((i | j) != 1) && ((i | j) != 2) && ((i | j) != 4)
                                && ((j | k) != 1) && ((j | k) != 2) && ((j | k) != 4)
                                && ((i | k) != 1) && ((i | k) != 2) && ((i | k) != 4)) {
                            if (i == j && j == k) {
                                total += (long) (regions[i] + 2) * (long) (regions[i] + 1) * (long) (regions[i]) / 6;
                            } else if (i == j) {
                                total += ((long) (regions[i] + 1) * (long) (regions[i]) / 2) * regions[k];
                            } else if (j == k) {
                                total += ((long) (regions[j] + 1) * (long) (regions[j]) / 2) * regions[i];
                            } else if (i == k) {
                                total += ((long) (regions[i] + 1) * (long) (regions[i]) / 2) * regions[j];
                            } else {
                                total += regions[i] * regions[j] * regions[k];
                            }
                        }
                    }
                }
            }
            
            System.out.println(total);
            
            /*
            For any in (a, b) only, then it's just in (a,b) only * any divisor in c
            in (b, c) only, then (b, c) only * a, etc
            in (a, b, c) then * a only, b only, c only, (a, b), (b, c), (c, a)
            */
        }
    }

}
