#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
inline int add(int x, int y) {
  x += y;
  return x >= mod ? x - mod : x;
}
inline int qpow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (long long)ans * a % mod;
    a = (long long)a * a % mod;
    b >>= 1;
  }
  return ans;
}
const int maxn = 60;
int R;
int base;
int in[maxn << 1][maxn << 1];
int L[maxn << 1], RR[maxn << 1], D[maxn << 1], U[maxn << 1];
struct emm {
  int a[maxn << 1];
  emm() { memset(a, 0, sizeof a); }
  emm operator+(const emm& x) const {
    emm ans;
    for (int i = 0; i < maxn * 2; i++) ans.a[i] = add(a[i], x.a[i]);
    return ans;
  }
  emm operator-(const emm& x) const {
    emm ans;
    for (int i = 0; i < maxn * 2; i++) ans.a[i] = add(a[i], mod - x.a[i]);
    return ans;
  }
  emm operator*(int x) const {
    emm ans;
    for (int i = 0; i < maxn * 2; i++) ans.a[i] = (long long)a[i] * x % mod;
    return ans;
  }
} zero, zt[maxn << 1][maxn << 1];
int bk[maxn << 1][maxn << 1];
int p1, p2, p3, p4, pp;
int fc[maxn << 1][maxn << 1];
int ans[maxn << 1];
void gs(int n) {
  for (int i = 1; i <= n; i++) {
    int j = i;
    while (j <= n && fc[j][i] == 0) j++;
    if (i != j) {
      for (int k = i; k <= n + 1; k++) {
        swap(fc[i][k], fc[j][k]);
      }
    }
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      int ra = (long long)fc[j][i] * qpow(fc[i][i], mod - 2) % mod;
      for (int k = i; k <= n + 1; k++) {
        fc[j][k] = add(fc[j][k], mod - (long long)fc[i][k] * ra % mod);
      }
    }
  }
  for (int i = 1; i <= n; i++)
    ans[i] = (long long)fc[i][n + 1] * qpow(fc[i][i], mod - 2) % mod;
}
int main() {
  scanf("%d", &R);
  scanf("%d%d%d%d", &p1, &p2, &p3, &p4);
  pp = add(add(p1, p2), add(p3, p4));
  p1 = (long long)p1 * qpow(pp, mod - 2) % mod;
  p2 = (long long)p2 * qpow(pp, mod - 2) % mod;
  p3 = (long long)p3 * qpow(pp, mod - 2) % mod;
  p4 = (long long)p4 * qpow(pp, mod - 2) % mod;
  base = R + 1;
  for (int i = 0; i < (maxn << 1); i++)
    L[i] = D[i] = 1000, RR[i] = U[i] = -1000;
  for (int i = -R - 1; i <= R + 1; i++) {
    for (int j = -R - 1; j <= R + 1; j++) {
      int dd = i * i + j * j;
      if (dd <= R * R)
        in[i + base][j + base] = 1, L[j + base] = min(L[j + base], i),
                         RR[j + base] = max(RR[j + base], i),
                         D[i + base] = min(D[i + base], j),
                         U[i + base] = max(U[i + base], j);
      else if (i <= 0 || j == R + 1 || j == -R - 1)
        zt[i + base][j + base] = zero, bk[i + base][j + base] = 1;
    }
  }
  for (int j = -R; j <= R; j++) {
    zt[L[j + base] + base][j + base].a[j + base] = 1;
    bk[L[j + base] + base][j + base] = 1;
  }
  for (int i = -R; i <= R + 1; i++) {
    for (int j = -R; j <= R; j++) {
      if (!bk[i + base][j + base]) {
        const emm a = in[i - 1 + base][j + 1 + base]
                          ? zt[i - 1 + base][j + 1 + base]
                          : zero,
                  b = in[i - 1 + base][j + base] ? zt[i - 1 + base][j + base]
                                                 : zero,
                  c = in[i - 1 + base][j - 1 + base]
                          ? zt[i - 1 + base][j - 1 + base]
                          : zero,
                  d = in[i - 2 + base][j + base] ? zt[i - 2 + base][j + base]
                                                 : zero;
        zt[i + base][j + base] = (b - d * p3 - a * p2 - c * p4);
        (zt[i + base][j + base].a[0] += mod - 1) %= mod;
        zt[i + base][j + base] = zt[i + base][j + base] * qpow(p1, mod - 2);
      }
    }
  }
  for (int j = -R; j <= R; j++) {
    for (int i = -R; i <= R; i++) {
      fc[j + base][i + base] =
          zt[RR[j + base] + base + 1][j + base].a[i + base];
    }
    fc[j + base][R + base + 1] =
        (mod - zt[RR[j + base] + base + 1][j + base].a[0]) % mod;
  }
  gs(R + base);
  int Ans = 0;
  for (int i = -R; i <= R; i++) {
    Ans = add(Ans, (long long)zt[base][base].a[i + base] * ans[i + base] % mod);
  }
  Ans = add(Ans, zt[base][base].a[0]);
  printf("%d\n", Ans);
  return 0;
}
