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<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef vector<vector<ll> >vvi;
ll mod = 1000000007;
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll po[111][11111];
vvi calc(int x, int y, int tim)
{
	vvi r;
	r.resize(x + 1);
	for (int i = 0; i < r.size(); i++)r[i].resize(y + 1);
	r[0][0] = 1;
	for (int i = 0; i < x; i++)
	{
		for (int j = 0; j <= y; j++)
		{
			for (int k = 0; k <= y - j; k++)
			{
				for (int l = 0; l <= j; l++)
				{
					if (k + l == 0)continue;
					r[i + 1][j + k] += r[i][j] * com(j + k, k) % mod*com(j, l) % mod*po[tim][k + l];
					r[i + 1][j + k] %= mod;
				}
			}
		}
	}
	return r;
}
ll get2d(int a, int b, int na, int nb)
{
	return (po[a][nb - 1] + po[b][na - 1] - 1)*a*b%mod;
}
ll get1(int a, int b, int c, int na, int nb, int nc)
{
	ll s = get2d(a, b, na, nb);
	ll r = 1;
	for (int i = 0; i < nc; i++)r = r*s%mod;
	return r*c%mod;
}
ll get2(int a, int b, int c, int na, int nb, int nc)
{
	return po[c][na*nb] * a*b%mod;
}
ll getusual(int a, int b, int c, int na, int nb, int nc)
{
	ll s = get1(a, b, c, na, nb, nc) + get1(b, c, a, nb, nc, na) + get1(c, a, b, nc, na, nb);
	ll t = get2(a, b, c, na, nb, nc) + get2(b, c, a, nb, nc, na) + get2(c, a, b, nc, na, nb);
	return (s + mod - t%mod + a*b*c) % mod;
}
int main()
{
	int a, b, c, na, nb, nc;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &na, &nb, &nc);
	if (na%a != 0 || nb%b != 0 || nc%c != 0)
	{
		printf("0\n");
		return 0;
	}
	invinit();
	na /= a, nb /= b, nc /= c;
	for (int i = 0; i < 111; i++)
	{
		po[i][0] = 1;
		for (int j = 1; j < 11111; j++)po[i][j] = po[i][j - 1] * i%mod;
	}
	ll ans = getusual(a, b, c, na, nb, nc);
	if (a == 1 || b == 1 || c == 1)
	{
		printf("%lld\n", ans);
		return 0;
	}
	vvi ma = calc(na, nc, b - 1), mb = calc(nb, nc, a - 1), mc = calc(na, nb, c - 1);
	ll add = 0;
	for (int i = 1; i <= na - 1; i++)
	{
		for (int j = 1; j <= nb - 1; j++)
		{
			ll tim = mc[i][j] * com(na, i) % mod*com(nb, j) % mod*a*b*c%mod;
			vector<ll>s;
			s.push_back(0);
			for (int k = 1; k <= nc - 1; k++)
			{
				ll sum = 0;
				for (int l = 1; l <= na - i; l++)
				{
					sum += ma[l][k] * com(na - i, l);
					sum %= mod;
				}
				s.push_back(sum);
			}
			vector<ll>t;
			t.push_back(0);
			for (int k = 1; k <= nc - 1; k++)
			{
				ll sum = 0;
				for (int l = 1; l <= nb - j; l++)
				{
					sum += mb[l][k] * com(nb - j, l);
					sum %= mod;
				}
				t.push_back(sum);
			}
			ll ss = 0;
			for (int k = 1; k <= nc - 1; k++)
			{
				for (int l = 1; l <= nc - k; l++)
				{
					ll x = s[k] * t[l] % mod;
					ll y = com(nc, k)*com(nc - k, l) % mod;
					ss = (ss + x*y) % mod;
				}
			}
			add = (add + ss*tim) % mod;
		}
	}
	printf("%lld\n", (ans + add) % mod);
}