atcoder#APC001J. Rectangles
Rectangles
Score : points
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:
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 .
1 1 1 2 2 2
1
2 2 2 4 4 4
744
2 3 4 6 7 8
0
2 3 4 98 99 100
471975164