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 std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 200;
const int mo = 1e9 + 7;

int fpm(int x, int y) {
    int res = 1;
    for(; y > 0; y >>= 1) {
        if(y & 1) 
            res = (ll) res * x % mo;
        x = (ll) x * x % mo;
    }
    return res;
}

int solve(int a, int A, int b, int B) {
    int res = 0;
    res = (res + (ll) fpm(a, B / b) * b) % mo;
    res = (res + (ll) fpm(b, A / a) * a) % mo;
    res = (res - (ll) a * b) % mo;
    return res;
}

int solve(int a, int A, int b, int B, int c, int C) {
    int res = 0;
    res = (res + (ll) fpm(solve(b, B, c, C), A / a) * a) % mo;
    res = (res + (ll) fpm(solve(a, A, c, C), B / b) * b) % mo;
    res = (res + (ll) fpm(solve(a, A, b, B), C / c) * c) % mo;
    res = (res - (ll) fpm(a, (B / b) * (C / c)) * b * c) % mo;
    res = (res - (ll) fpm(b, (A / a) * (C / c)) * a * c) % mo;
    res = (res - (ll) fpm(c, (A / a) * (B / b)) * a * b) % mo;
    res = (res + (ll) a * b * c) % mo;
    return res;
}

int ans;
int a, b, c, A, B, C;
int f[N + 5][N + 5], binom[N + 5][N + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(a), read(b), read(c), read(A), read(B), read(C);

    if(A % a || B % b || C % c) return puts("0"), 0;

    ans = solve(a, A, b, B, c, C);

    for(int i = 0; i <= N; ++i) {
        binom[i][0] = binom[i][i] = 1;
        for(int j = 1; j < i; ++j) {
            binom[i][j] = (binom[i-1][j] + binom[i-1][j-1]) % mo;
        }
    }

    int ma = A / a, mb = B / b;

    for(int i = ma; i > 0; --i) {
        for(int j = mb; j > 0; --j) {
            f[i][j] = (ll) binom[ma][i] * binom[mb][j] % mo * fpm(c, (ma - i) * (mb - j)) % mo;

            for(int k = i; k <= ma; ++k)
                for(int l = j; l <= mb; ++l) if(k > i || l > j) {
                    f[i][j] = (f[i][j] - (ll) f[k][l] * binom[k][i] % mo * binom[l][j]) % mo;
                }

            if(i < ma || j < mb) {
                int res = 1;
                res = (res + fpm((fpm(b, i) + fpm(a, j) - 1) % mo, C / c)) % mo;
                res = (res - fpm(fpm(b, i), C / c)) % mo;
                res = (res - fpm(fpm(a, j), C / c)) % mo;
                res = (ll) res * a * b * c % mo;
                ans = (ans + (ll) res * f[i][j]) % mo;
            }
        }
    }

    ans = (ans + mo) % mo;
    printf("%d\n", ans);

    return 0;
}
