#apc001j. [apc001_j]Rectangles

[apc001_j]Rectangles

Problem Statement

We have a rectangular parallelepiped of dimensions A×B×CA×B×C, divided into 1×1×11×1×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) mod AA, (q+j)(q + j) mod BB, (r+k)(r + k) mod C)C\\ ) | ii, jj and kk are integers satisfying 00 ii << aa, 00 jj << bb, 00 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×b×c.

Find the number of the sets of torus cuboids of size a×b×ca×b×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×B×C.

Constraints

  • 11 aa << AA 100100
  • 11 bb << BB 100100
  • 11 cc << CC 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×b×c that satisfy the condition, modulo 109+710^9+7.


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