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>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int A,B,C,a,b,c;
int ans;
int binom[105][105],f[105][105],g[105][105];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
int Calc(int a,int A,int b,int B) {
    int res = 0;
    update(res,mul(b,fpow(a,B / b)));
    update(res,mul(a,fpow(b,A / a)));
    update(res,MOD - mul(a,b));
    return res;
}
void Trivial() {
    update(ans,mul(c,fpow(Calc(a,A,b,B),C / c)));
    update(ans,mul(b,fpow(Calc(a,A,c,C),B / b)));
    update(ans,mul(a,fpow(Calc(b,B,c,C),A / a)));
    update(ans,MOD - mul(mul(b,c),fpow(a,B / b * C / c)));
    update(ans,MOD - mul(mul(a,c),fpow(b,A / a * C / c)));
    update(ans,MOD - mul(mul(a,b),fpow(c,A / a * B / b)));
    update(ans,mul(mul(a,b),c));
    
}
void Solve() {
    Trivial();
    binom[0][0] = 1;
    for(int i = 1 ; i <= 100 ; ++i) {
	binom[i][0] = 1;
	for(int j = 1 ; j <= i ; ++j) {
	    binom[i][j] = inc(binom[i - 1][j - 1],binom[i - 1][j]);
	}
    }
    for(int i = 0 ; i <= A / a ; ++i) {
	for(int j = 0 ; j <= B / b ; ++j) {
	    int t = 1;
	    for(int k = 0 ; k <= i ; ++k) {
		int tmp = inc(fpow(c,i - k),MOD - 1);
		tmp = fpow(tmp,j);
		update(g[i][j],mul(mul(tmp,binom[i][k]),t));
		t = mul(t,MOD - 1);
	    }
	}
    }
    int all = 0;
    for(int i = 1 ; i <= A / a ; ++i) {
	for(int j = 1 ; j <= B / b ; ++j) {
	    if(i == A / a && j == B / b) continue;
	    int k = fpow(a,j),t = fpow(b,i);
	    update(f[i][j],fpow(inc(inc(k,t),MOD - 1),C / c));
	    update(f[i][j],MOD - fpow(k,C / c));
	    update(f[i][j],MOD - fpow(t,C / c));
	    update(f[i][j],1);
	    int tmp = mul(f[i][j],mul(binom[A / a][i],binom[B / b][j]));
	    tmp = mul(tmp,c);
	    tmp = mul(tmp,g[A / a - i][B / b - j]);
	    update(all,tmp);
	}
    }
    all = mul(all,mul(a,b));
    update(ans,all);
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(a);read(b);read(c);read(A);read(B);read(C);
    if(A % a == 0 && B % b == 0 && C % c == 0) Solve();
    else puts("0");
    return 0;
}
