Hexagram#3336

Hexagram

1 second
32 megabytes
Easy

A Hexagram is a -pointed star, sometimes called the Star of David. Consider the numbers:

There are four unique ways of assigning the numbers to the vertices of the hexagram such that all of the sets of four numbers along the lines have the same sum ( in this case). All other ways may be obtained from these by rotation and/or reflection.

Given distinct numbers, in how many ways, disregarding rotations and reflections, can you assign the numbers to the vertices so that the sum of the numbers along each of the straight lines passing through vertices is the same?

Input

There will be several test cases in the input. Each test case will consist of twelve unique positive integers on a single line, with single spaces separating them. All of the numbers will be less than . The input will end with a line with twelve s.

Output

For each test case, output the number of ways the numbers can be assigned to vertices such that the sum along each line of the hexagram is the same. Put each answer on its own line. Output no extra spaces, and do not separate answers with blank lines.

Examples

Example 1

Loading
Loading