We have a rectangular parallelepiped of dimensions A×B×C, divided into 1×1×1 small cubes. The small cubes have coordinates from (0, 0, 0) through (A-1, B-1, C-1).

Let p, q and r be integers. Consider the following set of abc small cubes:

\\{(\ (p + i) mod A, (q + j) mod B, (r + k) mod C\ ) | i, j and k are integers satisfying 0 ≤ i < a, 0 ≤ j < b, 0 ≤ k < c \\}

A set of small cubes that can be expressed in the above format using some integers p, q and r, is called a torus cuboid of size a×b×c.

Find the number of the sets of torus cuboids of size a×b×c that satisfy the following condition, modulo 10^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×C.

Constraints

* 1 ≤ a < A ≤ 100
* 1 ≤ b < B ≤ 100
* 1 ≤ c < C ≤ 100
* All input values are integers.

Input

Input is given from Standard Input in the following format:


a b c A B C


Output

Print the number of the sets of torus cuboids of size a×b×c that satisfy the condition, modulo 10^9+7.

Examples

Input

1 1 1 2 2 2


Output

1


Input

2 2 2 4 4 4


Output

744


Input

2 3 4 6 7 8


Output

0


Input

2 3 4 98 99 100


Output

471975164
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 105;
const int mod = 1e9 + 7;

inline int Qow(int x, int y) {
  int r = 1;
  for (; y; y >>= 1, x = 1LL * x * x % mod) {
    if (y & 1) {
      r = 1LL * r * x % mod;
    }
  }
  return r;
}


inline int Solve(int a, int A) {
  return a;
}

inline int Solve(int a, int A, int b, int B) {
  int ans = 0;
  ans = (1LL * b * Qow(Solve(a, A), B / b) + ans) % mod;
  ans = (1LL * a * Qow(Solve(b, B), A / a) + ans) % mod;
  ans = (ans - a * b + mod) % mod;
  return ans;
}

inline int Solve(int a, int A, int b, int B, int c, int C) {
  static int f[N][N], bin[N][N];
  int ans = 0;
  ans = (1LL * c * Qow(Solve(a, A, b, B), C / c) + ans) % mod;
  ans = (1LL * b * Qow(Solve(a, A, c, C), B / b) + ans) % mod;
  ans = (1LL * a * Qow(Solve(b, B, c, C), A / a) + ans) % mod;
  ans = (ans - 1LL * b * c * Qow(Solve(a, A), B / b * C / c) % mod + mod) % mod;
  ans = (ans - 1LL * a * c * Qow(Solve(b, B), A / a * C / c) % mod + mod) % mod;
  ans = (ans - 1LL * a * b * Qow(Solve(c, C), A / a * B / b) % mod + mod) % mod;
  ans = (ans + a * b * c) % mod;
  for (int i = 0; i <= max(A / a, B / b); ++i) {
    bin[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      bin[i][j] = (bin[i - 1][j] + bin[i - 1][j - 1]) % mod;
    }
  }
  for (int i = A / a; i; --i) {
    for (int j = B / b; j; --j) {
      f[i][j] = 1LL * bin[A / a][i] * bin[B / b][j] % mod * Qow(c, (A / a - i) * (B / b - j)) % mod;
      for (int k = i; k <= A / a; ++k) {
        for (int l = j; l <= B / b; ++l) {
          if (k != i || l != j) {
            f[i][j] = (f[i][j] - 1LL * f[k][l] * bin[k][i] % mod * bin[l][j] % mod + mod) % mod;
          }
        }
      }
      if (i == A / a && j == B / b) {
        continue;
      }
      int tmp = 0;
      tmp = (tmp + Qow(Qow(b, i) + Qow(a, j) - 1, C / c)) % mod;
      tmp = (tmp - Qow(Qow(b, i), C / c) + mod) % mod;
      tmp = (tmp - Qow(Qow(a, j), C / c) + mod) % mod;
      tmp = (tmp + 1) % mod;
      tmp = 1LL * tmp * a * b * c % mod;
      ans = (1LL * f[i][j] * tmp + ans) % mod;
    }
  }
  return ans;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  int a, b, c, A, B, C;
  Read(a), Read(b), Read(c), Read(A), Read(B), Read(C);
  if (A % a || B % b || C % c) {
    puts("0");
  } else {
    printf("%d\n", Solve(a, A, b, B, c, C));
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}
