p01012 Planarian Regeneration_32091
Notes

For this problem, it is recommended to use floating point numbers, which are more accurate than double.



Input


m n x
k l y


For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cut x times and the vertical k: l cut y times.
1 ≤ m, n, k, l ≤ 100, 0 ≤ x, y ≤ 40, and m, n and l, k are relatively prime.

Output

Print out the expected number of planarians that are regenerating to their original form after a few weeks in a row.
The output is acceptable with an error of 10-6 or less.

Examples

Input

1 1 1
1 1 1


Output

0.562500


Input

1 2 2
1 1 1


Output

0.490741


Input

1 2 0
3 4 0


Output

1.000000
#include <bits/stdc++.h>
using namespace std;

int cnt[45][45] = {0};
long double dis[45][45] = {0};
long double sum[45][45] = {0};
int m, n, x;
long double ans = 1;

long double solve();

int main() {
  cout << fixed << setprecision(12);
  int t;
  for(t = 0; t < 2; ++t) {
    cin >> m >> n >> x;
    ans *= solve();
    for(int i = 0; i < 44; ++i)
      for(int j = 0; j < 44; ++j)
        cnt[i][j] = dis[i][j] = sum[i][j] = 0;
  }
  cout << ans << endl;
  return 0;
}

long double solve() {
  long double nans = 0;
  int i, j;
  long double mn = (long double)(m + n);
  cnt[0][0] = sum[0][0] = 1;
  for(i = 0; i < 44; ++i) dis[0][i] = 1;
  for(i = 1; i <= x; ++i) {
    for(j = 0; j < i; ++j) {
      cnt[i][j] += cnt[i - 1][j];
      cnt[i][j + 1] += cnt[i - 1][j];
    }
    for(j = 0; j <= x; ++j) {
      if(j < i)
        dis[i][j] = dis[i - 1][j] * (long double)m / mn;
      else
        dis[i][j] = dis[i - 1][j] * (long double)n / mn;
    }
    for(j = 0; j < i; ++j) {
      sum[i][j] += sum[i - 1][j];
      sum[i][j + 1] +=
          sum[i - 1][j] -
          dis[i][j] * (long double)cnt[i - 1][j];
    }
  }
  for(i = 0; i <= x; ++i) nans += sum[x][i] * dis[x][i];
  return nans;
}
