Cubes

You are given 12 rods of equal length. Each of them is colored in certain color. Your task is to determine in how many different ways one can construct a cube using these rods as edges. Two cubes are considered equal if one of them could be rotated and put next to the other, so that the corresponding edges of the two cubes are equally colored. Input The first line of input contains T (1 ≤ T ≤ 60), the number of test cases. Then T test cases follow. Each test case consists of one line containing 12 integers. Each of them denotes the color of the corresponding rod. The colors are numbers between 1 and 6. Output The output for one test consists of one integer on a line — the number of ways one can construct a cube with the described properties. Sample Input 3 122222222222 112222222222 112233445566 Sample Output 1 5 312120