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). 
//package CodeForces;

import java.io.*;
import java.util.*;

public class pave {

	public static void main(String[] args) throws IOException {
		FastScanner input = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

		int t = input.nextInt();
		int[][] dim = new int[t][3];
		int max = 0;
		for (int i=0; i<t; i++) {
			dim[i][0] = input.nextInt();
			dim[i][1] = input.nextInt();
			dim[i][2] = input.nextInt();
			if (Math.max(dim[i][0], Math.max(dim[i][1], dim[i][2]))>max) max = Math.max(dim[i][0], Math.max(dim[i][1], dim[i][2]));
		}
		
		ArrayList<Integer> primes = new ArrayList<Integer>();
		boolean[] counted = new boolean[max];
		for (int i=1; i<max; i++) {
			counted[i] = false;
		}
		counted[0] = true;
		for (int i=2; i<=max; i++) {
			if (counted[i-1]==false) {
				for (int j=1; j<=t/i; j++) {
					counted[i*j-1] = true;
				}
				primes.add(i);
			}
		}
		
		int[][] counter = new int[primes.size()][3];
		for (int i=0; i<primes.size(); i++) {
			counter[i][0] = 0;
			counter[i][1] = 0;
			counter[i][2] = 0;
		}
	
		for (int i=0; i<t; i++) {
			for (int j=0; j<3; j++) {
				for (int k=0; k<primes.size(); k++) {
					counter[k][j] = 0;
				}
			}
			for (int j=0; j<3; j++) {
				int temp = dim[i][j];
				for (int k=0; k<primes.size(); k++) {
					if (temp % primes.get(k) == 0) {
						temp/=primes.get(k);
						counter[k][j]++;
						k--;
					}
					if (temp==1) k = primes.size();
				}
			}
			
			int same = 1;
			int diff1 = 1;
			int diff2 = 1;
			int diff3 = 1;

			for (int j=0; j<primes.size(); j++) {
				same*=Math.min(Math.min(counter[j][0]+1,  counter[j][1]+1), counter[j][2]+1);
			}
			
			// second and third are the same
			int temp1 = 1;
			for (int j=0; j<primes.size(); j++) {
				temp1*=Math.min(counter[j][1]+1, counter[j][2]+1);
				temp1*=(counter[j][0]+1);
			}
			
			int temp2 = 1;
			for (int j=0; j<primes.size(); j++) {
				temp2*=Math.min(counter[j][0]+1, counter[j][2]+1);
				temp2*=(counter[j][1]+1);
			}
			
			int temp3 = 1;
			for (int j=0; j<primes.size(); j++) {
				temp3*=Math.min(counter[j][1]+1, counter[j][0]+1);
				temp3*=(counter[j][2]+1);
			}

			int sum = temp1+temp2+temp3;
			sum-=same*2;
			int fin = 1;
			for (int j=0; j<primes.size(); j++) {
				fin*=(counter[j][0]+1);
				fin*=(counter[j][1]+1);
				fin*=(counter[j][2]+1);
			}
			fin-=sum;
			fin/=6;
			sum-=(same*(same-1)*2);
			sum+=fin;
			System.out.println(sum);
		}
		out.close();
	}

	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		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++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String next() {
			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 String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}
