#APC001J. Rectangles

Rectangles

Score : 21002100 points

Problem Statement

We have a rectangular parallelepiped of dimensions A×B×CA \times B \times C, divided into 1×1×11 \times 1 \times 1 small cubes. The small cubes have coordinates from (0,0,0)(0, 0, 0) through (A1,B1,C1)(A-1, B-1, C-1).

Let pp, qq and rr be integers. Consider the following set of abcabc small cubes:

{( (p+i)\{(\ (p + i) mod AA, (q+j)(q + j) mod BB, (r+k)(r + k) mod C )C\ ) | ii, jj and kk are integers satisfying 00 \leq ii << aa, 00 \leq jj << bb, 00 \leq kk << cc }\}

A set of small cubes that can be expressed in the above format using some integers pp, qq and rr, is called a torus cuboid of size a×b×ca \times b \times c.

Find the number of the sets of torus cuboids of size a×b×ca \times b \times c that satisfy the following condition, modulo 109+710^9+7:

  • 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 A×B×CA \times B \times C.

Constraints

  • 11 \leq aa << AA \leq 100100
  • 11 \leq bb << BB \leq 100100
  • 11 \leq cc << CC \leq 100100
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

aa bb cc AA BB CC

Output

Print the number of the sets of torus cuboids of size a×b×ca \times b \times c that satisfy the condition, modulo 109+710^9+7.

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