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 int long long
#define mod 1000000007
#define nn 408
void add(int &x,int y){
	x=(x+y)%mod;
}
int qpow(int x,int y=mod-2){
	int res=1;while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}
int fort(int a,int A,int b,int B){
	int ans=0;
	add(ans,a*qpow(b,A/a));
	add(ans,b*qpow(a,B/b));
	add(ans,-a*b);
	return ans;
}
int A,B,C,a,b,c,ans;
void foltest(){
	add(ans,a*qpow(fort(b,B,c,C),A/a));
	add(ans,b*qpow(fort(a,A,c,C),B/b));
	add(ans,c*qpow(fort(b,B,a,A),C/c));
	add(ans,-a*b%mod*qpow(c,(A/a)*(B/b)));
	add(ans,-a*c%mod*qpow(b,(A/a)*(C/c)));
	add(ans,-b*c%mod*qpow(a,(C/c)*(B/b)));
	add(ans,a*b%mod*c);
}

int f[nn],rf[nn];
int cc(int x,int y){
	if(x<y) return 0;
	return f[x]*rf[y]%mod*rf[x-y]%mod;
}
int solve(){
	rf[0]=f[0]=1;for(int i=1;i<nn;i++) f[i]=f[i-1]*i%mod,rf[i]=qpow(f[i]);
	int ans=0;
	
	for(int p=1;p<=A/a;p++) for(int q=1;q<=B/b;q++){
		if(p==A/a and q==B/b) continue;
		int t=C/c;t=qpow(qpow(b,p)+qpow(a,q)-1,t)-qpow(qpow(a,q),t)-qpow(qpow(b,p),t)+1;t%=mod;
		t=t*cc(A/a,p)%mod*cc(B/b,q)%mod;
		int extra=0;
		for(int i=0,ff=1;i<=A/a-p;i++,ff=-ff){
			int res=cc(A/a-p,i);
			res=res*qpow(qpow(c,A/a-p-i)-1,B/b-q);
			add(extra,ff*res);
		}
		add(ans,t*extra%mod*c);
	}
	
	
	return ans*a%mod*b%mod;	
}

signed main(){
	cin>>a>>b>>c>>A>>B>>C;
	if(A%a or B%b or C%c) return puts("0")*0;
	foltest();
	add(ans,solve());
	ans%=mod;ans+=mod;cout<<ans%mod;
	return 0;
} 