#include <bits/stdc++.h>
using namespace std;
const int N = 102, p = 1e9 + 7;
int r, a, b, c, d, e, tot, cnt, opt, w[N], q[N][N], f[N][N][N];
int fl[N][N];
inline int pows(long long u, int v) {
  long long ans = 1;
  while (v > 0) {
    if (v & 1) ans = ans * u % p;
    u = u * u % p, v = v >> 1;
  }
  return ans;
}
inline int inc(int a, int b) {
  if (a + b >= p) return a + b - p;
  return a + b;
}
inline int sub(int a, int b) {
  if (a - b < 0) return a - b + p;
  return a - b;
}
inline int mul(int a, int b) { return 1ll * a * b % p; }
inline void gauss() {
  memset(w, 0, sizeof(w));
  for (int i = 1; i <= tot; i++) {
    for (int c = i; c <= tot; c++) {
      if (!q[c][i]) continue;
      for (int x = 0; x <= tot; x++) swap(q[i][x], q[c][x]);
      break;
    }
    int inv = pows(q[i][i], p - 2);
    for (int c = i + 1; c <= tot; c++) {
      int t = mul(q[c][i], inv);
      for (int x = 0; x <= tot; x++) q[c][x] = sub(q[c][x], mul(t, q[i][x]));
    }
  }
  for (int i = tot; i >= 0; i--) {
    int ans = q[i][0];
    for (int x = i + 1; x <= tot; x++) ans = sub(ans, mul(q[i][x], w[x]));
    ans = mul(ans, pows(q[i][i], p - 2)), w[i] = ans;
  }
}
int main() {
  cin >> r >> a >> b >> d >> c, e = a + b + c + d;
  a = mul(a, pows(e, p - 2)), b = mul(b, pows(e, p - 2));
  c = mul(c, pows(e, p - 2)), d = mul(d, pows(e, p - 2));
  for (int i = -r; i <= r; i++)
    for (int j = -r; j <= r; j++)
      if (i * i + j * j <= r * r) fl[i + r][j + r] = 1;
  for (int j = -r; j <= r; j++)
    for (int i = -r; i <= r; i++)
      if (i * i + j * j <= r * r) {
        f[i + r][j + r][++tot] = 1, fl[i + r][j + r] = 2;
        break;
      }
  for (int i = -r; i <= r; i++)
    for (int j = -r; j <= r; j++)
      if (fl[i + r][j + r] == 1) {
        for (int k = 0; k <= tot; k++) w[k] = f[i + r - 1][j + r][k];
        for (int k = 0; k <= tot; k++)
          if (i + r - 2 >= 0) w[k] = sub(w[k], mul(f[i + r - 2][j + r][k], d));
        for (int k = 0; k <= tot; k++)
          w[k] = sub(w[k], mul(f[i + r - 1][j + r - 1][k], b));
        for (int k = 0; k <= tot; k++)
          w[k] = sub(w[k], mul(f[i + r - 1][j + r + 1][k], c));
        if (i - 1 == 0 && j == 0) w[0] = p - 1;
        int wn = pows(a, p - 2);
        for (int k = 0; k <= tot; k++) f[i + r][j + r][k] = mul(w[k], wn);
      }
  for (int j = r; j >= -r; j--)
    for (int i = r; i >= -r; i--)
      if (i * i + j * j <= r * r) {
        cnt++;
        for (int k = 0; k <= tot; k++) w[k] = f[i + r][j + r][k];
        for (int k = 0; k <= tot; k++)
          w[k] = sub(w[k], mul(f[i + r - 1][j + r][k], d));
        for (int k = 0; k <= tot; k++)
          w[k] = sub(w[k], mul(f[i + r][j + r - 1][k], b));
        for (int k = 0; k <= tot; k++)
          w[k] = sub(w[k], mul(f[i + r][j + r + 1][k], c));
        w[0] = sub(0, w[0]);
        if (i == 0 && j == 0) w[0] = inc(w[0], 1);
        for (int k = 0; k <= tot; k++) q[cnt][k] = w[k];
        break;
      }
  gauss();
  for (int i = -r; i <= r; i++)
    for (int j = -r; j <= r; j++) {
      opt = inc(opt, f[i + r][j + r][0]);
      for (int k = 1; k <= tot; k++)
        opt = inc(opt, mul(f[i + r][j + r][k], w[k]));
    }
  cout << opt << endl;
}
