A hexagram is a six-pointed star, also called the Star of David. It is drawn as two overlapping equilateral triangles and has $12$ vertices: $6$ outer points (the tips of the star) and $6$ inner points (where the edges of the two triangles cross). It also has $6$ straight lines. Each line is one full side of a triangle: it starts at an outer point, passes through two inner points, and ends at another outer point, so every line passes through exactly $4$ vertices. Every vertex lies on exactly $2$ of the $6$ lines.
Given $12$ distinct numbers, in how many ways, disregarding rotations and reflections, can you assign the numbers to the $12$ vertices so that the four numbers along each of the $6$ lines have the same sum? Two assignments that can be turned into each other by a rotation or a reflection of the star are counted as the same.
There are several test cases. Each test case is a single line containing twelve distinct positive integers separated by single spaces; every number is less than $1{,}000{,}000$. The input ends with a line of twelve zeros, which is not processed.
For each test case, print on its own line the number of ways the numbers can be assigned to the vertices so that the sum along each of the $6$ lines is the same. Print no extra spaces, and do not separate the answers with blank lines.