#apc001j. [apc001_j]Rectangles
[apc001_j]Rectangles
Problem Statement
We have a rectangular parallelepiped of dimensions , divided into small cubes. The small cubes have coordinates from through .
Let , and be integers. Consider the following set of small cubes:
\\{(\\ (p + i) mod , mod , mod , and are integers satisfying , , \\}
A set of small cubes that can be expressed in the above format using some integers , and , is called a torus cuboid of size .
Find the number of the sets of torus cuboids of size that satisfy the following condition, modulo :
- No two torus cuboids in the set have intersection.
- The union of all torus cuboids in the set is the whole rectangular parallelepiped of dimensions .
Constraints
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of the sets of torus cuboids of size that satisfy the condition, modulo .
Sample Input 1
1 1 1 2 2 2
Sample Output 1
1
Sample Input 2
2 2 2 4 4 4
Sample Output 2
744
Sample Input 3
2 3 4 6 7 8
Sample Output 3
0
Sample Input 4
2 3 4 98 99 100
Sample Output 4
471975164